Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the solution (thanks to the @Itay Moav):</p> <pre><code>if (!AJAX) var AJAX = {}; else if (AJAX &amp;&amp; typeof(AJAX) != "object") throw new Error("AJAX is not an Object type"); AJAX = { NAME: "AJAX scripts", VERSION: 1.0, initAJAX: function(){ var objxml = null; var ProgID = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Microsoft.XMLHTTP"]; try{ objxml = new XMLHttpRequest(); } catch(e){ for (var i = 0; i &lt; ProgID.length; i++){ try{ objxml = new ActiveXObject(ProgID[i]); } catch(e){ continue; } } } return objxml; }, getAJAXResponseText: function(xhr){ var outObj = {}; outObj.outMsg = ""; outObj.loadingFlag = false; outObj.errorFlag = false; if (!xhr){ outObj.outMsg = "The request has expired"; outObj.loadingFlag = false; outObj.errorFlag = true; }else if (xhr.readyState == 4){ if (xhr.status == 200){ outObj.outMsg = xhr.responseText; outObj.loadingFlag = false; outObj.errorFlag = false; }else{ outObj.outMsg = "There was a problem with the request " + xhr.status; outObj.loadingFlag = false; outObj.errorFlag = true; } }else{ if (xhr.status == 200){ outObj.loadingFlag = true; outObj.errorFlag = false; }else{ outObj.outMsg = "There was a problem with the request " + xhr.status; outObj.loadingFlag = false; outObj.errorFlag = true; } } return outObj; } } </code></pre> <p>And this:</p> <pre><code>window.onload = makeRequest; var xhr = false; var currMsg; var timer; function makeRequest() { currMsg = document.getElementById("updateArea").innerHTML; xhr = AJAX.initAJAX(); if (xhr) { xhr.onreadystatechange = showState; xhr.open("GET", "colors.xml", true); timer = setTimeout(function(){xhr = null;}, 2000); // can't delete the object xhr.send(null); } else { document.getElementById("updateArea").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest"; } } function showState() { var retObj = AJAX.getAJAXResponseText(xhr); if (!retObj.errorFlag){ if (retObj.loadingFlag) { document.getElementById("updateArea").innerHTML = currMsg + "&lt;h2&gt;Loading...&lt;/h2&gt;"; }else{ clearTimeout(timer); document.getElementById("updateArea").innerHTML = currMsg + "&lt;p&gt;" + retObj.outMsg + "&lt;/p&gt;"; } }else{ document.getElementById("updateArea").innerHTML = currMsg + "&lt;p&gt;" + retObj.outMsg + "&lt;/p&gt;"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload