xmlHttpRequest =null;
function ajaxSubmit(){
if(window.ActiveXObject){
xmlHttpRequest=new ActiveXObject("Micsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttpRequest=new XMLHttpRequest();
}
if(null!=xmlHttpRequest){
xmlHttpRequest.open("POST","AjaxServlet",true);
//注册回调函数
//这个状态的值改变了就会触发自己定义的ajaxCallBack函数
xmlHttpRequest.onreadystatechange=ajaxCallBack;
//post 传递参数
xmlHttpRequest.setRequestHeader("contentType", "application/x-www-form-urlencoded");
//真正向服务器端发送函数
xmlHttpRequest.send();
}
}
function ajaxCallBack(){
//完整的收到响应
if(xmlHttpRequest.readyState==4){
//正确完成
if(xmlHttpRequest.status==200){
var responseText=xmlHttpRequest.responseText;
alert(responseText);
}
}
}
function ajaxSubmit(){
if(window.ActiveXObject){
xmlHttpRequest=new ActiveXObject("Micsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttpRequest=new XMLHttpRequest();
}
if(null!=xmlHttpRequest){
xmlHttpRequest.open("POST","AjaxServlet",true);
//注册回调函数
//这个状态的值改变了就会触发自己定义的ajaxCallBack函数
xmlHttpRequest.onreadystatechange=ajaxCallBack;
//post 传递参数
xmlHttpRequest.setRequestHeader("contentType", "application/x-www-form-urlencoded");
//真正向服务器端发送函数
xmlHttpRequest.send();
}
}
function ajaxCallBack(){
//完整的收到响应
if(xmlHttpRequest.readyState==4){
//正确完成
if(xmlHttpRequest.status==200){
var responseText=xmlHttpRequest.responseText;
alert(responseText);
}
}
}