作者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