作者herman602 (奸商)
看板Ajax
標題Fw: [問題] onsubmit無效
時間Sat Aug 25 16:40:44 2012
※ [本文轉錄自 Web_Design 看板 #1GE8z-Lz ]
作者: herman602 (奸商) 看板: Web_Design
標題: [問題] onsubmit無效
時間: Sat Aug 25 16:40:26 2012
以下是我的程式碼
主要問題是rsp.success返回true的時候
表單還是無法submit出去....
有誰知道原因嗎....
謝謝!
<script type="text/javascript">
var ajaxCheck = function(customForm) {
// fetch the data for the form
var data = $(customForm).serializeArray();
// setup the ajax request
$.ajax({
type: "POST",
dataType: 'json',
url: "check.php",
data: data,
cache: false,
success: function(rsp){
if (rsp.success == true)
return true;
else
return false;
}
});
return true;
}
</script>
<form method="post" id="customForm" name="customForm" action="submit.php"
onsubmit="return ajaxCheck(this);">
...(略)
<input type="submit" id="send" name="send" value="送出" />
</form>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.68.58.22
※ 發信站: 批踢踢實業坊(ptt.cc)
※ 轉錄者: herman602 (219.68.58.22), 時間: 08/25/2012 16:40:44
1F:→ StockVirtual:在IE上的話,可能是因語法有錯而導致整段程式不能用 08/25 17:33
2F:→ herman602:我是用FF 14 ...@@ 08/25 17:43
3F:推 Fantasywind:既然都用jq了 直接用jq綁event看看吧 08/25 18:20
4F:→ herman602:我解決了....我validation的JS, 也在submit之前檢查 08/25 18:42
5F:→ herman602:結果那段js, 有些情況不會return true ... 08/25 18:42
6F:→ herman602:(沒貼在這的部分出錯) 我耍笨了 0rz 謝謝以上幾位 08/25 18:43
7F:→ herman602:跟丟我水球的人XD 08/25 18:43