jQuery防止表单多次提交
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery防止表单多次提交相关的知识,希望对你有一定的参考价值。
To prevent multiple submit from sending more than one request,bind the submit event and store a "disabledOnSubmit" data. Next time the event "submit" will be fire, the following jQuery code will return false. All submit buttons are also disabled (nice user feedback).
$(document).ready(function() { $('form').submit(function() { if(typeof jQuery.data(this, "disabledOnSubmit") == 'undefined') { jQuery.data(this, "disabledOnSubmit", { submited: true }); $('input[type=submit], input[type=button]', this).each(function() { $(this).attr("disabled", "disabled"); }); return true; } else { return false; } }); });
以上是关于jQuery防止表单多次提交的主要内容,如果未能解决你的问题,请参考以下文章