by
18
7
2,363
0
Top 1% !
Popular
Famous
Nice
Tagged
Specified
MultiPlatform
Popularity: 7765th place
Languagejavascript
LicenseMIT_X11
TechnologyAJAX

XHR + a fallback...

...so krappy old browsers can do ajax to!
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/143068/XHR---a-fallback---?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// simple request with a fallback function getAjax() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } try { return new ActiveXObject('MSXML2.XMLHTTP.6.0'); } catch (err) { try { // fallback. return new ActiveXObject('MSXML2.XMLHTTP.3.0'); } catch (err) { alert('AJAX is not enabled.'); return null; } } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus