Optimized XHR factory
This commit is contained in:
parent
de7b9a7b80
commit
f2f68fc1ee
|
@ -1,18 +1,24 @@
|
||||||
function getXHR(){
|
try {
|
||||||
var xhr;
|
new ActiveXObject("Msxml2.XMLHTTP");
|
||||||
|
getXHR = function() {
|
||||||
|
return new ActiveXObject("Msxml2.XMLHTTP");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
xhr = new ActiveXObject("Msxml2.XMLHTTP");
|
new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
getXHR = function() {
|
||||||
|
return new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
if (typeof XMLHttpRequest !== 'undefined') {
|
||||||
xhr = new ActiveXObject("Microsoft.XMLHTTP");
|
getXHR = function() {
|
||||||
} catch (e) {
|
return new XMLHttpRequest();
|
||||||
xhr = false;
|
}
|
||||||
|
} else {
|
||||||
|
alert("Something went really wrong!");
|
||||||
|
console.log("XHR is not available");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!xhr && typeof XMLHttpRequest !== 'undefined') {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
}
|
|
||||||
return xhr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getURL(url, params, callback) {
|
function getURL(url, params, callback) {
|
||||||
|
|
Loading…
Reference in New Issue