【发布时间】:2015-01-07 20:25:39
【问题描述】:
为解谜者准备的。
我想禁用提交按钮以防止重复提交。
为此,我使用 jQuery:
jQuery('#subnewtopicform').on('submit', function () {
jQuery('#subnewtopic').prop('disabled', true);
});
并剥离 HTML:
<form action="file.php" method="post" id="subnewtopicform">
<input type="text" name="title" />
<input type="submit" value="Submit" name="subnewtopic" id="subnewtopic" />
</form>
当点击提交按钮时,它被禁用并且页面重新加载但表单没有正确提交,为什么?!删除 jQuery 代码将使其正确提交。
在我 10 年的编码中,我还没有遇到过这么奇怪的事情。
【问题讨论】:
-
是否曾经向服务器执行过包含表单内容的请求?
-
@NathanTaylor 我怀疑内容从未发送过,这没有任何意义。
-
@HenrikPetterson 你怀疑还是你确定?这是关键。
-
@FastTrack 据我所知,没有发送实际数据。有什么好的检查方法吗?
-
“未正确提交”是什么意思?