mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(dom) RESTful: sendRequest
This commit is contained in:
parent
d60b76fe10
commit
3957aa6045
1 changed files with 32 additions and 34 deletions
|
|
@ -198,41 +198,39 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
});
|
||||
};
|
||||
|
||||
function sendRequest(pParams) {
|
||||
var lRet = Util.checkObjTrue(pParams, ['method']);
|
||||
if (lRet) {
|
||||
var p = pParams;
|
||||
|
||||
Images.showLoad( p.imgPosition );
|
||||
CloudCmd.getConfig(function(pConfig) {
|
||||
var lData;
|
||||
|
||||
if (Util.isString(p.url))
|
||||
p.url = decodeURI(p.url);
|
||||
|
||||
if (p.data &&
|
||||
!Util.isString(p.data) &&
|
||||
!Util.isArrayBuffer(p.data))
|
||||
lData = Util.stringifyJSON(p.data);
|
||||
else
|
||||
lData = p.data;
|
||||
|
||||
p.url = pConfig && pConfig.apiURL + p.url,
|
||||
DOM.ajax({
|
||||
method : p.method,
|
||||
url : p.url,
|
||||
data : lData,
|
||||
error : Images.showError,
|
||||
success : function(pData) {
|
||||
Images.hideLoad();
|
||||
Util.log(pData);
|
||||
Util.exec(p.callback, pData);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function sendRequest(params) {
|
||||
var p = params;
|
||||
|
||||
Images.showLoad(p.imgPosition);
|
||||
|
||||
return lRet;
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var data,
|
||||
isString = Util.isString(p.data),
|
||||
isArrayBuffer = Util.isArrayBuffer(p.data);
|
||||
|
||||
if (Util.isString(p.url))
|
||||
p.url = decodeURI(p.url);
|
||||
|
||||
if (p.data && !isString && !isArrayBuffer)
|
||||
data = Util.stringifyJSON(p.data);
|
||||
else
|
||||
data = p.data;
|
||||
|
||||
p.url = config && config.apiURL + p.url;
|
||||
|
||||
DOM.ajax({
|
||||
method : p.method,
|
||||
url : p.url,
|
||||
data : data,
|
||||
error : Images.showError,
|
||||
success : function(data) {
|
||||
Images.hideLoad();
|
||||
|
||||
Util.log(data);
|
||||
Util.exec(p.callback, data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue