作者j87b0003 (10Ways-拥抱高雄)
看板Ajax
标题[问题] 有关登入
时间Tue Nov 27 00:56:53 2007
不知道大家是怎麽做的?
因为是用thickbox开启一层的登入页面,如下:
呼叫loginFormSubmit()
程式码:
function loginFormSubmit(){
$(document).ready(function(){
$("form").submit(function() {
if (
check($("input:text").val(),$("input:password").val())) {
$("tt").text("登入成功").show();
//showbox();
return true;
}
else{
$("tt").text("登入失败").show().fadeOut(2500);
return false;
}
});
});
}
function check(account,password){
if(account == "" || password == "")return false;
else{
var str='account='+account+'&password='+password+'&login=true';
if(xmlhttp) {
xmlhttp.open("POST", "check.php", true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 &&xmlhttp.status ==200){
xmlResponse = xmlhttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
message = xmlDocumentElement.firstChild.data;
}
}
xmlhttp.send(str);
}
}
}
回传的xml,如果登入成功是1,失败是0
而我的问题是
因为等回传完的时候,程式早就跑完了...
如何改进?
谢谢各位指教
--
得罪,就
咒杀他。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.56.141.142
※ 编辑: j87b0003 来自: 61.56.141.142 (11/27 01:00)