<script>
var xhr=false;
function createXHR(){
try{
xhr=new ActiveXObject("MSXML.XMLHTTP");
}catch(e){
try{
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e2){
xhr=new XMLHttpRequest();
}
}
}
function tt(){
var loginname=document.getElementById("loginname").value;
createXHR();
xhr.open("post","dozhuce.jsp",true); //请求处理页面
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");//异步传输需要设置编码
xhr.send("loginname="+loginname);//发送的参数
xhr.onreadystatechange=changg;//回调的函数 } function changg(){ if(xhr.readyState==4){ if(xhr.status==200){ var data=xhr.responseText; alert(data); } } } </script> 原文链接:https://www.f2er.com/ajax/165823.html