Commit b2c24bd5 by dabai

xx

parent e3a8db78
Showing with 10 additions and 2 deletions
...@@ -53,14 +53,22 @@ function $ajax(opt) { ...@@ -53,14 +53,22 @@ function $ajax(opt) {
} }
xmlHttp.onreadystatechange = function() { xmlHttp.onreadystatechange = function() {
var res; var res;
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) { if(this.readyState != 4)return;
res = xmlHttp.responseText;
if( this.status == 200 || this.status == 304) {
res = this.responseText;
if(opt.dataType == 'json') { if(opt.dataType == 'json') {
res = JSON.parse(res); res = JSON.parse(res);
} }
resolve(res); resolve(res);
} else {
reject(new Error(this.statusText));
} }
}; };
xmlHttp.onerror = function() {
reject(new Error(this.statusText));
};
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment