0

I've been stuck with this issue for almost 3 days!

I have an input button: <input type="button" id="submit" value="Upload"/> Using jQuery 1.6.1, in the document.ready, I'm binding the button to submit the form like this:

$('#submit').click(function() {
     $('form').submit();
});

Using FireBug, the line $('form').submit(); causes an error with jquery! After 3 days of trying to figure out the issue, it seems that naming the input button id="submit" is what's causing the bug! When I changed the id to something else, it worked!

Any technical explanation to this?

evilReiko
  • 19,501
  • 24
  • 86
  • 102
  • 1
    possible duplicate of [How to javascript submit in the presence of an input id equal to 'submit'](http://stackoverflow.com/questions/4465028/how-to-javascript-submit-in-the-presence-of-an-input-id-equal-to-submit) – Matt May 27 '11 at 07:24

2 Answers2

1

jQuery form submit() is not working in IE6?

Community
  • 1
  • 1
run
  • 1,170
  • 7
  • 14
0

This has something to do with the browser. The browser see the input as an submit button when defining an Id with submit. simply use this code will solve the problem:

$('#submit').click(function() {
     $('form').submit();
     return false;
}); 
Michel
  • 9,220
  • 13
  • 44
  • 59