Skip to content

Instantly share code, notes, and snippets.

@defims
Forked from subzey/LICENSE.txt
Last active June 13, 2016 09:23
Show Gist options
  • Select an option

  • Save defims/511b15d786ca19af377b5efaf71fea94 to your computer and use it in GitHub Desktop.

Select an option

Save defims/511b15d786ca19af377b5efaf71fea94 to your computer and use it in GitHub Desktop.
140byt.es Cross-browser XHR
/* arguments are defined but ignored */
function(s, a){
/*
Here:
a = "Msxml2.XMLHTTP"
((anonymous array)) = ["Msxml2.XMLHTTP"]
((anonymous array)) = ["Msxml2.XMLHTTP", "Msxml2.XMLHTTP.3.0"]
((anonymous array)) = ["Msxml2.XMLHTTP", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP.6.0"]
a = ((that anonymous array))
*/
a = [a = "Msxml2.XMLHTTP", a + ".3.0", a + ".6.0"];
do /* try..catch do not requires {} */
try {
/*
Get the last element, so during the loop s variable is:
"Msxml2.XMLHTTP.6.0"
"Msxml2.XMLHTTP.3.0"
"Msxml2.XMLHTTP"
undefined
*/
s=a.pop();
/* try to return new... */ return new /* ... XHR if s==undefined (last iteration), AX if not */ (s ? ActiveXObject : XMLHttpRequest) /*... using s itself as an argument */(s)
} catch(e){
/* if it is failed do nothing and leave ; for very old version of Firefox */;
}
/* if s == undefined (and a.length == 0) that was a last iteration and exit */
while(s)
/* thats it, return undefined if all previous return attempts failed */
}
export function(s,a){a=[a="Msxml2.XMLHTTP",a+".3.0",a+".6.0"];do try{s=a.pop();return new(s?ActiveXObject:XMLHttpRequest)(s)}catch(e){;}while(s)}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "crossbrowser_XHR",
"description": "Function creates XMLHTTPRequest object in IE6+ and other browsers.",
"keywords": [ "xhr" ],
"version": "0.1.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment