JSFiddle - React, Tailwind, and code Playground

by Chase Wilson

HTML

<div id="times"></div>
<div id="catch"></div>

JavaScript

var XHR = (function(){
    var ins = [
        function(){return new ActiveXObject('Msxml2.XMLHTTP');},
        function(){return new ActiveXObject('Microsoft.XMLHTTP');},
        function(){return new XMLHttpRequest();}
        
    ],i,tmp;
    
    return (function tryIns(i){
        i = i || 0;
        $('times').set('text','Looped '+ (i + 1) +' Times');
        while(i < ins.length){
            try{tmp = ins[i]();return ins[i]}
            catch(e){i++; tryIns(i);}
        }
        throw new Error("Your browser doesn\'t support Ajax requests");
    })();
})();

var xhrInstance = XHR();
$('catch').set('text',xhrInstance);