Simplest Ajax example code (complete comment)
<Input type = "button" onclick = "ajaxtest ()" value = "ajax test"> <input type = "button" onclick = "document. getelementbyid ('weate '). innerhtml = ''" value = "hide"> <SCRIPT> // 1. initialize the request object // var XMLHTTP = new XMLHttpRequest () under Mozilla/Firefox; // var XMLHTTP = new activexobject ("Microsoft. XMLHTTP ") // alert (XMLHTTP); function ajaxtest () {// specify the page to open XMLHTTP. open ("get", "staticpage.html", true); // HTTP Request Method, URL, asynchronous or not // specifies the operation to be performed after the page is opened. XMLHTTP. onreadystatechange = mychange; // start to initiate a browser request. Mozilla must add null XMLHTTP. send (null);} // This function is the function mychange () to be called every time the state changes {// The request has been completed if (XMLHTTP. readystate = 4) {// alert (XMLHTTP. readystate); alert (XMLHTTP. responsetext); // update the content displayed in the corresponding HTML element // reference the document element in the page based on the ID. getelementbyid (element name) document. getelementbyid ('weate '). innerhtml = XMLHTTP. responsetext ;}</SCRIPT> <Div id = "Weather"> </div>