use plain XMLHttpRequest instead of goog.net.XhrIo

This commit is contained in:
Bart van den Eijnden
2013-11-08 20:34:03 +01:00
parent dc0dc32d6b
commit cc4c0bda60
+10 -9
View File
@@ -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();
} }