Ajax core code
/*** Created by luby on 2015/8/8. */var xmlHttp; // create the ajax object function xmlHttpRequest () {if (window. activeXObject) {// xml http = new ActiveXObject ('Microsoft. XMLHTTP ');} else if (window. XMLHttpRequest) {// Firefox and other browsers xmlHttp = new XMLHttpRequest () ;}} function dianji () {// js trigger object xmlHttpRequest (); // reference the ajax object var username = document. myform. username. value; // get user data xmlHttp. open ("GET", ". php? Id = "+ username, true); // open the xmlHttp connection. onreadystatechange = luyi; // triggers the object xmlHttp. send (null); // send request} function luyi () {if (xmlHttp. readyState = 1) {document. getElementById ('xiance '). innerHTML = "loading... ";} if (xmlHttp. readyState = 4) {if (xmlHttp. status = 200) {var result = xmlHttp. responseText; document. getElementById ('xiance '). innerHTML = result; // return value }}