home *** CD-ROM | disk | FTP | other *** search
- // i18n - issue
- // Error Message
- var xml_get_problem="Problem retrieving Data from the Server";
- var xml_set_problem="Problem updating Data on the Server";
- var dummy_data = "dummy=dummy";
- // Global Variables to read the XML response files from server
- // The XML Object used for the Request
- var xmlDoc;
- // The XML Content
- var xmlContent;
-
- //Function that downloads the XML Data. Uses POST to avoid caching.
- function processXMLData(url)
- {
- // code for Mozilla, etc.
- if (window.XMLHttpRequest)
- {
- xmlDoc=new XMLHttpRequest()
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=loadXMLData;
- xmlDoc.open("POST",url,false)
- xmlDoc.send("dummy")
- loadXMLData();
- }
- // code for IE
- else if (window.ActiveXObject)
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
- if (xmlDoc)
- {
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=loadXMLData;
- xmlDoc.open("POST",url,false)
- xmlDoc.send("dummy")
- loadXMLData();
- }
- }
- }
-
- //Function that Loads the XML Data
- function loadXMLData()
- {
- // Once Data is Downloaded...
- if (xmlDoc.readyState==4)
- {
- // if "OK"
- if (xmlDoc.status==200)
- {
- xmlContent = xmlDoc.responseXML;
- }
- else
- {
- alert(xml_get_problem)
- }
- }
- }
-
- //Function that Sends the XML Data to the Server
- function sendXMLData(url, data)
- {
- // code for Mozilla, etc.
- if (window.XMLHttpRequest)
- {
- xmlDoc=new XMLHttpRequest()
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=loadXMLData;
- xmlDoc.open("POST",url,false)
- xmlDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xmlDoc.send((data != "") ? data : dummy_data)
- loadXMLData();
- }
- // code for IE
- else if (window.ActiveXObject)
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
- if (xmlDoc)
- {
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=loadXMLData;
- xmlDoc.open("POST",url,false)
- xmlDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xmlDoc.send((data != "") ? data : dummy_data)
- loadXMLData();
- }
- }
- }
-
- //Function that downloads the XML Data
- function processXMLDataUsingGet()
- {
- // code for Mozilla, etc.
- if (window.XMLHttpRequest)
- {
- xmlDoc=new XMLHttpRequest()
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=loadXMLData;
- xmlDoc.open("GET",url,false)
- xmlDoc.send(null)
- loadXMLData();
- }
- // code for IE
- else if (window.ActiveXObject)
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
- if (xmlDoc)
- {
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=loadXMLData;
- xmlDoc.open("GET",url,false)
- xmlDoc.send()
- loadXMLData();
- }
- }
- }
-
- function SendAsynchornousRequest(url, postData, callback, info)
- {
- var asyncDoc;
- var data = info;
-
- // inner function.
- function CheckDataArrived()
- {
- // Once Data is Downloaded...
- if (asyncDoc.readyState==4)
- {
- // if "OK"
- if (asyncDoc.status==200)
- {
- callback(asyncDoc.responseXML, data);
- }
- }
- }
-
- // code for Mozilla, etc.
- if (window.XMLHttpRequest)
- {
- asyncDoc=new XMLHttpRequest();
- //Need this if this is to be done asynchronously
- asyncDoc.onreadystatechange=CheckDataArrived;
- asyncDoc.open("POST",url,true);
- asyncDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- asyncDoc.send((postData != "") ? postData : dummy_data)
- }
- // code for IE
- else if (window.ActiveXObject)
- {
- asyncDoc=new ActiveXObject("Microsoft.XMLHTTP");
- if(asyncDoc)
- {
- //Need this if this is to be done asynchronously
- asyncDoc.onreadystatechange=CheckDataArrived;
- asyncDoc.open("POST",url,true);
- asyncDoc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- asyncDoc.send((postData != "") ? postData : dummy_data)
- }
- }
-
- return asyncDoc;
- }
-
- function SendSynchornousRequest(url, callback, info)
- {
- var syncDoc;
- var data = info;
-
- // code for Mozilla, etc.
- if (window.XMLHttpRequest)
- {
- syncDoc=new XMLHttpRequest();
- syncDoc.open("POST",url,false);
- syncDoc.send("dummy");
- }
- // code for IE
- else if (window.ActiveXObject)
- {
- syncDoc=new ActiveXObject("Microsoft.XMLHTTP");
- if(syncDoc)
- {
- syncDoc.open("POST",url,false);
- syncDoc.send("dummy");
- }
- }
- if (syncDoc.readyState==4)
- {
- // if "OK"
- if (syncDoc.status==200)
- {
- callback(syncDoc.responseXML, data);
- }
- else
- {
- alert(xml_get_problem)
- }
- }
- }
-
-
- /* OLD FUNCTIONs:
- function sendXMLDataUsingGet()
- {
- // code for Mozilla, etc.
- if (window.XMLHttpRequest)
- {
- xmlDoc=new XMLHttpRequest()
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=checkXMLDataLoaded;
- xmlDoc.open("GET",url,false)
- xmlDoc.send(null)
- checkXMLDataLoaded();
- }
- // code for IE
- else if (window.ActiveXObject)
- {
- xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
- if (xmlDoc)
- {
- //Need this if this is to be done asynchronously
- //xmlDoc.onreadystatechange=checkXMLDataLoaded;
- xmlDoc.open("GET",url,false)
- xmlDoc.send()
- checkXMLDataLoaded();
- }
- }
- }
-
- //Check the uploaded XML
- function checkXMLDataLoaded()
- {
- // Once Data is Downloaded...
- if (xmlDoc.readyState==4)
- {
- // if "OK"
- if (xmlDoc.status!=200)
- {
- alert(xml_set_problem)
- }
- }
- }
- */
-