feature(util) rm isContainStr

This commit is contained in:
coderaiser 2014-10-28 09:41:14 -04:00
parent ad87145c42
commit 5d4db87a96
5 changed files with 10 additions and 46 deletions

View file

@ -194,7 +194,7 @@ var Util, DOM;
});
Events.add('readystatechange', xhr, function(event) {
var TYPE_JSON, type, data, isContain,
var TYPE_JSON, type, data, isContain, notText,
xhr = event.target;
if (xhr.readyState === 4 /* Complete */) {
@ -204,14 +204,13 @@ var Util, DOM;
if (xhr.status === 200 /* OK */) {
data = xhr.response;
isContain = Util.isContainStr(type, TYPE_JSON);
notText = p.dataType !== 'text',
isContain = ~type.indexOf(TYPE_JSON);
if (p.dataType !== 'text')
/* If it's json - parse it as json */
if (type && isContain)
data = Util.json.parse(xhr.response) || xhr.response;
if (type && isContain && notText)
data = Util.json.parse(xhr.response) || xhr.response;
Util.exec(p.success, data, xhr.statusText, xhr);
Util.exec(p.success, data, xhr.statusText, xhr);
}
/* file not found or connection lost */
else {