Created
June 8, 2011 12:57
-
-
Save maartenJacobs/1014367 to your computer and use it in GitHub Desktop.
HTTPObject (Bulletproof) in a configobject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As seen in Bulletproof Ajax (The warrior, not the faulty abbreviation), by Jeremy Keith | |
var httpObject = function(){ | |
if(window.XMLHttpRequest){ | |
httpObject = function(){ | |
return new XMLHttpRequest(); | |
}; | |
} else if(window.ActiveXObject) { | |
var xhr; | |
try{ | |
xhr = new ActiveXObject("Msxml2.XMLHTTP"); | |
httpObject = function(){ | |
return new ActiveXObject("Msxml2.XMLHTTP"); | |
}; | |
} catch(e) { | |
// Disregard error, acquire HTTPObject | |
try{ | |
xhr = new ActiveXObject("Microsoft.XMLHTTP"); | |
httpObject = function(){ | |
return new ActiveXObject("Microsoft.XMLHTTP"); | |
}; | |
} catch(e) { | |
httpObject = function(){ | |
// I give up. | |
return false; | |
}; | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment