Revision: 24023
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 18, 2010 16:33 by alvincrespo
Initial Code
/* Author: Alvin Crespo Description: XMLLoader */ //xml object variable var xmlhttp; function loadXMLDoc(dname,type){ //get the proper xml object (based on browser of user) xmlhttp = GetXMLHTTPObject(); //if no object was found, tell the user that their browser is not supported if (xmlhttp==null){ alert ("Your browser is not supported!"); return; //break the current function loadXMLDoc } //keep track of the state xmlhttp.onreadystatechange = function(){ //finishing state if (xmlhttp.readyState==4){ //successful codes: 200 for webserver and 0 for local if (xmlhttp.status == 200 || xmlhttp.status == 0){ //process code here if(type == "contact-cards") createContactCards(xmlhttp.responseXML); //located at contactcards.js if(type == "contact-profile") createProfile(xmlhttp.responseXML); //located at profiles.js } //let the user know that there was an error loading the xml document else{ //should handle the error better alert("Error Loading XML"); } } } //get the document and keep track of what is happening in a queue by setting asynch to true xmlhttp.open("GET",dname,true); xmlhttp.send(""); } //get the proper xml object function GetXMLHTTPObject(){ if (window.XMLHttpRequest){ // for all browsers besides ie 5 and 6 and perhaps 7 return new XMLHttpRequest(); }else if (window.ActiveXObject){ // catch ie 5/6/7 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } //END OF XML LOADING
Initial URL
Initial Description
Initial Title
Loading XML Using Raw Javascript
Initial Tags
ajax, javascript, xml, load
Initial Language
JavaScript