topical media & game development

talk show tell print

professional-javascript-16-IEXMLHttpRequestExample2.htm / htm

          <title>XML HTTP Request Example</title>
          <script type="text/javascript">
                  function createXMLHTTP() {
                      var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
                                           "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                      for (var i=0; i < arrSignatures.length; i++) {
                          try {
                              var oRequest = new ActiveXObject(arrSignatures[i]);
                              return oRequest;
                          } catch (oError) {
                      throw new Error("MSXML is not installed on your system.");               
                  function getServerInfo() {
                          var oRequest = createXMLHTTP();
                "get", "example.xml", false);
                          alert("Status is " + oRequest.status + " (" + oRequest.statusText + ")");
                          alert("Response text is: " + oRequest.responseText);
                          alert("Tag name of document element is: " + oRequest.responseXML.childNodes.length);
          <p>Click the button to make a call to the server using an XML HTTP request.
          This example may not function properly when running outside of a Web server.</p>
          <input type="button" onclick="getServerInfo()" value="Get Server info" />

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.