window.onload = function(){
document.getElementById("ok").onclick = function(){
var xhr = ajaxFunction();
xhr.open("POST", "../servlet/testServlet?timeStamp=" + new Date().getTime(), true);
//如果请求类型是POST的话,需要设置请求头部信息Content-Type
//application/x-www-form-urlencoded
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("a=7&b=8");
xhr.onreadystatechange = function(){
if (xhr.readyState == 4) {
alert(xhr.status);
if (xhr.status == 200 || xhr.status == 304) {
alert("tfy");
var data=xhr.responseText;
alert(data);
}
}
}
}
}
document.getElementById("ok").onclick = function(){
var xhr = ajaxFunction();
xhr.open("POST", "../servlet/testServlet?timeStamp=" + new Date().getTime(), true);
//如果请求类型是POST的话,需要设置请求头部信息Content-Type
//application/x-www-form-urlencoded
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("a=7&b=8");
xhr.onreadystatechange = function(){
if (xhr.readyState == 4) {
alert(xhr.status);
if (xhr.status == 200 || xhr.status == 304) {
alert("tfy");
var data=xhr.responseText;
alert(data);
}
}
}
}
}