我需要禁用许多不同页面上的许多窗体的提交按钮后,他们被点击,以便该窗体只能提交一次。从jQuery提交不起作用
我知道检查双重提交的正确方法是更好地完成服务器端,而不仅仅是禁用按钮,但我正在寻找一个现在应该做的简单解决方案。
这里是其中一个按钮:
<input type="submit" value="Save" />
这里是我写的
$(document).ready(function(){
$("input").each(function(index){
//find all submit buttons with value "Save"
if($(this).attr("value")=="Save"){
console.log(index);
$(this).click(function(){
//disable the button
$(this).attr("disabled","true");
console.log("save btn clicked");
//submit the form
var form = $(this).closest("form");
console.log(form.attr("action"));
form.submit();
});
}
});
});
一切工作正常,直到我在那里尝试提交部分脚本,该按钮只是禁止罚款。问题是它没有提交(它没有这个脚本)。
为什么不提交?我没有找到表单或..?
如果做工精细是什么问题? –
@CoderJohn忘了最基本的部分...问这个问题 – vlatkozelka
你能告诉我按钮的HTML代码吗?可能是您使用