ajax-manager
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "ajax-manager", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "An jQuery ajax management tool", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -88,3 +88,3 @@ # ajax-manager | ||
You can write config in both model difinition config, `ajaxManager(m, globalConfig, j)` and `API(config)`.You can find all the accepted config in [jQuery.ajax](http://api.jquery.com/jQuery.ajax/). All the config will be merged in one object just like `Object.assign(ajaxManagerConfig, modelDifinitionConfig, apiCallingConfig)` except events. | ||
You can write config in both model difinition config, `ajaxManager(m, globalConfig, j)` and `API(config)`.You can find all the accepted config in [jQuery.ajax](http://api.jquery.com/jQuery.ajax/). All the config will be merged in one object just like `Object.assign(globalConfig, modelConfig, apiCallingConfig)` except events and `data`. | ||
@@ -115,4 +115,69 @@ ## Events | ||
## `Data` | ||
All the `data` field in those 3 configs will merge into an object(Just like `Object.assign(globalConfigData, modelConfigData, apiCallingConfigData)`) insteadof cover one by one. | ||
```javascript | ||
var userModels = { | ||
getUsers: { | ||
methods: 'GET', | ||
url: 'http://127.0.0.1/get_users', | ||
data: { | ||
origin: 'user' | ||
} | ||
} | ||
} | ||
var globalConfig = { | ||
data: { | ||
type: 'app' | ||
} | ||
} | ||
var apis = ajaxManager([userModels], globalConfig, $) | ||
api.getUsers({ | ||
data: { | ||
auth: '123456abcdef' | ||
} | ||
}, true, true) | ||
// finally when fire ajax, the data will be | ||
/* | ||
{ | ||
origin: 'user', | ||
type: 'app', | ||
auth: '123456abcdef' | ||
} | ||
*/ | ||
``` | ||
## `__apiRoot` | ||
Use `__apiRoot` field to indicate the backend api root, it will concat in front of the `url`. GlobalConfig, modelConfig and apiCallingConfig are all accept this field. | ||
```javascript | ||
var userModels = { | ||
getUsers: { | ||
methods: 'GET', | ||
url: '/get_users', | ||
}, | ||
getUserInfoById: { | ||
methods: 'GET', | ||
url: '/get_user_info_by_id' | ||
} | ||
} | ||
var globalConfig = { | ||
__apiRoot: 'http://192.168.0.1' | ||
} | ||
var apis = ajaxManager([userModels], globalConfig, $) | ||
api.getUsers({ | ||
data: { | ||
auth: '123456abcdef' | ||
} | ||
}, true, true) | ||
// finally when fire ajax, the url will be 'http://192.168.0.1/get_users' and 'http://192.168.0.1/get_user_info_by_id' | ||
``` | ||
# TODO LIST: | ||
* useage examples |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13493
181