我想写一个代码登录,登录ajax将用户名和密码发送到服务器,然后服务器将返回结果。我的问题是我无法从xmlhttp拆分responeText ... 我的js:
function kiemTraDangNhap(usrname, pass) {
var xmlhttp;
//
if (usrname == "" || pass == "") {
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var kq = xmlhttp.responseText.split("--");
document.getElementById("notice").innerHTML = kq[0];
}
}
xmlhttp.open("POST", "LoginAjax.aspx", true);
//
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("un="+usrname+"&"+"pass="+pass);
}
LoginAjax.aspx:
//Do some thing with databse, example it respone this:
Response.Write("Info--Success");
document.getElementById(“notice”)。innerHTML = kq [0];什么都不显示。
有什么想法吗?