Share via


Source: XMLOverHTTP.js

 

This JScript code example makes a synchronous request for an XML document over HTTP.

JScript Source File (XMLOverHTTP.js)

main();

function main()
{
   try {
     var xhr = new ActiveXObject("MSXML2.XMLHTTP.6.0");
     xhr.open("GET",
              "https://localhost/sxh/contact.asp?SearchID=John Doe",
              false);
     xhr.send();

     var doc = xhr.responseXML;
     alert(doc.xml);    
   }
   catch (e) {
     alert(e.description);
   }
}

function alert(s)
{
   WScript.Echo(s);
}

To add XMLOverHTTP.js to the project

  1. Copy the code listing above. Paste it into the JScript code editor, and save the file as XMLOverHTTP.js in the current project folder.

Next, we'll set up a virtual directory. You must complete this step before you build and run the application.