看板 Ajax 關於我們 聯絡資訊
不知道大家是怎麼做的? 因為是用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)