use plain XMLHttpRequest instead of goog.net.XhrIo
This commit is contained in:
+10
-9
@@ -2,22 +2,23 @@
|
|||||||
(function(global) {
|
(function(global) {
|
||||||
|
|
||||||
function afterLoad(type, path, next) {
|
function afterLoad(type, path, next) {
|
||||||
goog.net.XhrIo.send(path, function(event) {
|
var xhr = new XMLHttpRequest();
|
||||||
var xhr = event.target;
|
xhr.open('GET', path, true);
|
||||||
|
xhr.onload = function() {
|
||||||
var data;
|
var data;
|
||||||
if (xhr.isSuccess()) {
|
if (xhr.status == 200) {
|
||||||
if (type === 'xml') {
|
if (type === 'xml') {
|
||||||
data = xhr.getResponseXml();
|
data = xhr.responseXML;
|
||||||
} else if (type === 'json') {
|
|
||||||
data = xhr.getResponseJson();
|
|
||||||
} else {
|
} else {
|
||||||
data = xhr.getResponseText();
|
data = xhr.responseText;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(path + ' loading failed: ' + xhr.getStatus());
|
throw new Error(path + ' loading failed: ' + xhr.status);
|
||||||
}
|
}
|
||||||
next(data);
|
next(data);
|
||||||
});
|
xhr = null;
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user