Basic PHP development tutorial: Creating XMLHttpRequest
1. Create an XMLHttpRequest object
1. XMLHttpRequest is the basis of AJAX
2. XMLHttpRequest Object
The XMLHttpRequest object is supported by all modern browsers (IE5 and IE6 use ActiveXObject).
XMLHttpRequest is used to exchange data with the server in the background. This means that parts of a web page can be updated without reloading the entire page.
3. Syntax for creating XMLHttpRequest object:
All modern browsers (IE7+, Firefox, Chrome, Safari and Opera) have built-in XMLHttpRequest object.
Syntax for creating an XMLHttpRequest object:
variable=new XMLHttpRequest();
Old Versions of Internet Explorer (IE5 and IE6) use ActiveX objects:
variable=new ActiveXObject("Microsoft.XMLHTTP");
For For all modern browsers, including IE5 and IE6, please check whether the browser supports the XMLHttpRequest object. If supported, creates an XMLHttpRequest object. If not supported, create an ActiveXObject:
var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }