ajax-manager
Advanced tools
Comparing version
{ | ||
"name": "ajax-manager", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "An jQuery ajax management tool", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -167,2 +167,4 @@ # ajax-manager | ||
If your `type` is `post` and `content-type` set to `application/json`, you should use `JSON.stringify()` to parse your `data` to string when use origin jquery `ajax()`, but Ajax Manager have done this for you. Just pass your data object to it. | ||
## `__apiRoot` | ||
@@ -169,0 +171,0 @@ |
@@ -81,2 +81,3 @@ // use global count instead of jquery global event because it does't support cross domain request | ||
if (!models.__global) models.__global = {} | ||
if (!models.__default) models.__default = {} | ||
}) | ||
@@ -148,5 +149,7 @@ // globle config | ||
{}, | ||
models.__default || {}, | ||
registerConfig || {}, | ||
models[key] || {}, | ||
config, | ||
models.__global, | ||
{ | ||
@@ -181,10 +184,13 @@ url: getUrl(key, models[key], registerConfig, config), | ||
) | ||
// if got window api config then use it | ||
if (window.__apiConfig__ && window.__apiConfig__[key] && window.__apiConfig__[key].type) { | ||
allConfig = Object.assign({}, allConfig, window.__apiConfig__[key]) | ||
} | ||
// format data when post application json | ||
if (allConfig.contentType && allConfig.contentType.toLowerCase().trim() === 'application/json') { | ||
allConfig.data = JSON.stringify(allData) | ||
if ( | ||
allConfig.type.toLowerCase().trim() === 'post' && | ||
allConfig.contentType && | ||
allConfig.contentType.toLowerCase().trim() === 'application/json') { | ||
allConfig.data = JSON.stringify(allData) | ||
} | ||
// if got window api config use the type in it | ||
if (window.__apiConfig__ && window.__apiConfig__[key] && window.__apiConfig__[key].type) { | ||
allConfig.type = window.__apiConfig__[key].type | ||
} | ||
return $.ajax(allConfig) | ||
@@ -191,0 +197,0 @@ } |
20538
2.29%228
2.7%230
0.88%