I'm sorry for asking a question that there seems to be TONS of info on, but I don't seem to be getting anywhere.
开发者_StackOverflow社区I'm simply trying to stop a double form submission from happening, I'm using the following code:
<script language="javascript" src="/js/jquery-1.6.1.min.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#cc_form").submit(function() {
if ($.data($("#cc_form").get(0), 'submitting')) {
return false;
}
$.data($("#cc_form").get(0), 'submitting', true);
$(".submit",$("#cc_form")).prop('disabled', true);
});
});
</script>
It works fine in FF 4 and FF 5, it does not work in IE 8 or IE 9. In IE I get that "Object Expected" on the document.ready line. I've tried moving it from the head to just before the closing body, I tried using type=text/javascript
and language=javascript
, I've tried using jQuery(function()..
instead of document.ready
and no matter what I tried I get that error in IE and it does not stop multiple form submissions (while FF continues to work without any error).
Any Ideas?
One thing jumps out at me:
$(".submit",$("#cc_form")).prop('disabled', true);
Give this a shot:
<script language="javascript" src="/js/jquery-1.6.1.min.js"></script>
<script language="javascript">
$(document).ready(function(){
var cc_form = $("#cc_form");
cc_form.submit(function() {
if ($.data(this, 'submitting')) {
return false;
}
$.data(this, 'submitting', true);
$(".submit, #cc_form").attr('disabled', true); // Revert to .prop() if this is a working solution per comments
});
});
</script>
I'm all set - I don't know what to say. Just to try something different I downloaded the uncompressed version and it WORKED!. I then download the min again and even though they are the same to the byte on the filesystem, it worked!
精彩评论