AJAX script Support
<script language="javascript">
function requestData(id,url) {
req = false;
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} // end try
catch(e) {
req = false;
} // end catch(e)
// branch for IE/Windows ActiveX version
} // end if(window.XMLHttpRequest)
else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} // end try
catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} // end try
catch(e) {
req = false;
} // end catch(e)
} // end catch(e)
} // end else if(window.ActiveXObject)
if(req) {
req.onreadystatechange = processReqChange;
req.open("GET",url, true);
req.send("");
} // end if(req)
function processReqChange() {
var myLayer;
myLayer = document.getElementById(id);
switch(req.readyState){
case 0: myLayer.innerHTML = " attempting to retrieve data... ";
break;
case 1: myLayer.innerHTML = " loading data... ";
break;
case 2: myLayer.innerHTML = " loading complete. Preparing data for use ";
break;
case 3: myLayer.innerHTML = " data almost done ";
break;
case 4: if (req.status == 200) {
// ...processing statements go here...
var response = req.responseText;
myLayer.innerHTML = " successful ";
myLayer.innerHTML = response;
} // end if (req.status == 200)
else if(req.status == 404){
myLayer.innerHTML = "";
alert("No resource found:\n" + req.statusText);
}
else {
myLayer.innerHTML = "";
alert("There was a problem retrieving the XML data:\n" + req.statusText);
} // end else
break;
} // end switch(req.readyState)
} // end function processReqChange()
} // end function requestData(id,url)
requestData("Layer1","test.php");
</script>
<div id="Layer1">The retrieved data will be shown here </div>
Comments
test.php
You must me logged in to write a comment.