function Ajax () {var xmlhttpreq = null;//declares that an empty object is used to mount the XMLHttpRequest if window. ActiveXObject) {//ie5 IE6 is the ActiveXObject way to introduce xmlhttprequest xmlhttpreq = new ActiveXObject ("Microsoft.XMLHTTP");} else if (window. XMLHttpRequest) {///except IE5 IE6 browser XMLHttpRequest is a window's child object xmlhttpreq = new XMLHttpRequest ();//Instantiate a XMLHttpRequest} if (xmlhttpreq!= null) {//If the object is instantiated successfully xmlhttpreq.open ("Get", "test.jsp", true);//Call The Open () method and use asynchronous methods Xmlhttpreq.onreadystatechange=requestcallback; Sets the callback function xmlhttpreq.send (NULL); Because a Get method is committed, you can use the null parameter call} function Requestcallback () {//Once readyState value changes, this function will be called if (xmlhttpreq.readystate = = 4) { if (Xmlhttpreq.status = = 200) {//Assign Xmlhttpreq.responsetext value to element document.getElementById with ID resText ("resText"). InnerHTML = Xmlhttpreq.responsetext; } } } }
JavaScript's Ajax notation.