一个简单的ajax用户登陆返回值问题?有代码
來源:互聯網 2009-11-13 11:55:56 評論
分類: 電腦/網絡 >> 程序設計 >> 其他編程語言
問題描述:
————aaa.asp 文件————————————
Using responseText with innerHTMLvar xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function startRequest() {
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
//xmlHttp.open("post", "bb.html", true);
xmlHttp.open("POST", 'bbb.asp?name='+document.getElementById("name").value + "&pwd=" + document.getElementById("pwd").value, true);
//xmlHttp.open("POST", "bbb.asp", true);
xmlHttp.send(null);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
document.getElementById("results").innerHTML = xmlHttp.responseText;
}
}
}
姓名:
密码: