/* -- Function to "handle" the response -- */ function myHandler() { /* -- Was the request successful? -- */ if (this.readyState == 4 && this.status == 200) { /* -- Did the request return a result? -- */ if (this.responseXML != null && this.responseXML.getElementById("stuff").firstChild.data) { doSomething(this.responseXML.getElementById("stuff").firstChild.data); } } } var myRequest; // Variable to hold request object if (window.XMLHttpRequest) { myRequest = new XMLHttpRequest(); // Standards-compliant browsers } else if (window.ActiveXObject) { myRequest = new ActiveXObject("Msxml2.XMLHTTP"); // For IE } myRequest.onreadystatechange = myHandler; /* -- "getStuff.php" can be anything that returns an XML file -- */ myRequest.open("GET", "getStuff.php", true);