AJAX Structure
<script type="text/javascript">
/* -- 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;
/* -- "handleResponse.php" can be anything that returns an XML file -- */
myRequest.open("GET", "handleResponse.php", true);
</script>
source : http://www.phpwebs.com
/* -- 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;
/* -- "handleResponse.php" can be anything that returns an XML file -- */
myRequest.open("GET", "handleResponse.php", true);
</script>
source : http://www.phpwebs.com
No comments:
Post a Comment