fix parsing json response with charset

pull/43/merge
nightwing 2015-05-18 16:09:25 +04:00
rodzic d822cd5457
commit 69f1ae7f5a
1 zmienionych plików z 11 dodań i 14 usunięć

Wyświetl plik

@ -66,7 +66,7 @@ define(function(require, module, exports) {
return done(new Error("Could not serialize body as json"));
}
}
if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
else if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
body = qs.stringify(body);
}
else if (["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(body)) > -1) {
@ -75,7 +75,7 @@ define(function(require, module, exports) {
}
else {
body = body.toString();
}
}
}
var timer;
@ -105,18 +105,15 @@ define(function(require, module, exports) {
headers: parseHeaders(xhr.getAllResponseHeaders())
};
var data;
switch (options.overrideMimeType || res.headers["content-type"]) {
case "application/json":
try {
data = JSON.parse(xhr.responseText);
} catch (e) {
return done(e);
}
break;
default:
data = xhr.responseText;
var data = xhr.responseText;
if ((options.overrideMimeType || res.headers["content-type"])
.indexOf("application/json") === 0
) {
try {
data = JSON.parse(data);
} catch (e) {
return done(e);
}
}
if (this.status > 299) {