Created
November 23, 2009 03:33
-
-
Save yosmoc/240870 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| HTTP = {}; | |
| HTTP._factories = [ | |
| function() {return new XMLHttpRequest();}, | |
| function() {return new ActiveXObject("Msxml2.XMLHTTP");}, | |
| function() {return new ActiveXObject("Microsoft.XMLHTTP");} | |
| ]; | |
| HTTP._factory = null; | |
| HTTP.newRequest = function() { | |
| if (HTTP._factories != null) return HTTP._factory(); | |
| for (var i = 0; i < HTTP._factories.length; i++){ | |
| try { | |
| var factory = HTTP._factories[i]; | |
| var request = factory(); | |
| if (request != null) { | |
| HTTP._factory = factory; | |
| return request; | |
| } | |
| } catch(e) { | |
| continue; | |
| } | |
| } | |
| HTTP._factory = function() { | |
| throw new Error("XMLHttpRequest not supported"); | |
| } | |
| HTTP._factory(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment