Although many JS frameworks now provide Ajax call methods, we do not even have to understand their specific implementation of the principle can be directly invoked, but I do not think from the most basic level to understand a thing, it is difficult to do the best.
var xhr=null; if (window.
XMLHttpRequest) {//non ie kernel XHR = new XMLHttpRequest (); else if (window.
ActiveXObject) {//IE kernel, where the earlier version of IE is different, the specific query can be XHR = new ActiveXObject ("Microsoft.XMLHTTP");
else {XHR = null;
} if (XHR) {Xhr.open ("get", "ajaxserver.action");
Xhr.onreadystatechange = function () {//ReadyState value Description//0, initialization, XHR object created, open not yet executed
1, loading, has called the Open method, but has not sent the request//2, loading completed, request has been sent to complete//3, interactive, can receive part of the data
Status value Description//200: Success//404: No file found, query or URL//500: Server generated internal error if (xhr.readystate = = 4 && xhr.status = 200) {///Here you can handle the returned content//a
Returns JSON or XML data format console.log (xhr.responsetext);
Active release, JS itself will also be recycled XHR = null;
}
};
Xhr.send (); }