Introduction: Ajax is composed of HTML, JavaScript? The combination of technology, DHTML and DOM can transform clumsy Web interfaces into interactive Ajax applications. For Ajax, the core object is XMLHttpRequest. All Ajax operations cannot be separated from operations on this object. Create XMLHttpRequest
Introduction: Ajax is composed of HTML, JavaScript? The combination of technology, DHTML and DOM can transform clumsy Web interfaces into interactive Ajax applications. For Ajax, the core object is XMLHttpRequest. All Ajax operations cannot be separated from operations on this object. Create XMLHttpRequest
Introduction:
Ajax is composed of HTML, JavaScript? The combination of technology, DHTML and DOM can transform clumsy Web interfaces into interactive Ajax applications.
For Ajax, the core object is XMLHttpRequest. All Ajax operations cannot be separated from operations on this object.
Create an XMLHttpRequest object
For ie browsers:
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
For other browsers:
xmlHttp = new XMLHttpRequest();
Different browsers have different support for XMLHttpRequest objects in javascript, so you need to make a judgment based on the situation.
XMLHttpRequest object related methods
Open request
XMLHttpRequest. open (transfer method, address, asynchronous request or not)
Ready for execution
XMLHttpRequest.onreadystatechange
Obtain execution results
XMLHttpRequest.responseText
A simple php + Ajax example:
The first is the test. js file:
var xmlHttp;function S_xmlhttprequest(){if(window.ActiveXObject){xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');}else if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest();}}function php100(url){S_xmlhttprequest();xmlHttp.open("GET","do.php?id="+url,true);xmlHttp.onreadystatechange=byphp;xmlHttp.send(null);}function byphp(){var byphp100=xmlHttp.responseText;document.getElementById('php100').innerHTML=byphp100;}
Then the file that executes the php operation, do. php
The frontend display page, test.html