87,996
社区成员




function AjaxRequest()
{
//......
}
// Send an Ajax request to the server
AjaxRequest.prototype.send = function(type, url, handler, postDataType, postData)
{
if (this.request != null)
{
// Kill the previous request
this.request.abort();
// Tack on a dummy parameter to override browser caching
url += "?dummy=" + new Date().getTime();
try
{
this.request.onreadystatechange = handler;
this.request.open(type, url, true); // always asynchronous (true)
if (type.toLowerCase() == "get")
{
// Send a GET request; no data involved
this.request.send(null);
}
else
{
// Send a POST request; the last argument is data
this.request.setRequestHeader("Content-Type", postDataType);
this.request.send(postData);
}
}
catch(e)
{
alert("Ajax error communicating with the server.\n" + "Details: " + e);
}
}
}
document.getElementById("PcButton").onclick = function()
{
//1.最后的检测
var isQualified = false;
//检测过程
isQualified = validate();
//2.输送数据
if(isQualified == true)
{
var account = document.getElementById("Account").value;
var password = document.getElementById("Password").value;
user = new User(account,password);
ajaxReq = new AjaxRequest();
var postData = user.account + "&" + user.password;
ajaxReq.send("POST","Default.aspx",changeHandler,"application/x-www-form-urlencoded;charset=UTF-8",postData);
}
}