feature(rest) read: add optional dataType

This commit is contained in:
coderaiser 2014-05-21 03:49:55 -04:00
parent 0af0190688
commit afa89f38fa
2 changed files with 10 additions and 4 deletions

View file

@ -395,7 +395,7 @@ var Util, DOM, CloudFunc;
if (!isRefresh && json)
CloudCmd.createFileTable(obj, panel);
else
RESTful.read(cleanPath, function(json) {
RESTful.read(cleanPath, 'json', function(json) {
CloudCmd.createFileTable(json, panel);
Storage.set(cleanPath, json);
});

View file

@ -36,15 +36,21 @@ var Util, DOM, CloudFunc;
});
};
this.read = function(url, callback) {
var isQuery = Util.isContainStr(url, '?');
this.read = function(url, dataType, callback) {
var isQuery = Util.isContainStr(url, '?'),
isFunc = Util.isFunction(dataType);
if (!callback && isFunc) {
callback = dataType;
dataType = 'text';
}
sendRequest({
method : 'GET',
url : CloudFunc.FS + url,
callback : callback,
notLog : !isQuery,
dataType : 'text'
dataType : dataType
});
};