var xmlHttpReq =createXMLHttpRequest();//第一步,每次请求都需要重新创建一个XMLHttpRequest对象
var btype = getOs();
xmlHttpReq.open("get", "CheckUserServlet?action=checkUserName&userName=" + value, true);
xmlHttpReq.send();//第三步 发送请求
xmlHttpReq.onreadystatechange = listeningReadyState;//第四步 监听 处理响应后的数据
function listeningReadyState(){
alert("======");
}
xmlHttpReq.onreadystatechange = listeningReadyState; onreadystatechange 监听使用的listeningReadyState, js不执行。
------解决思路----------------------
ajax用这个吧http://www.w3school.com.cn/jquery/ajax_ajax.asp
------解决思路----------------------
xmlHttpReq.onreadystatechange = listeningReadyState;//调换位置
xmlHttpReq.send(null);
alert('send request')/////增加这句确认已经执行过send,而不是前面的代码出错导致没有send