Skip to content Skip to sidebar Skip to footer

Jquery Submit(); Not Working For Firefox

I am new in web development i am trying to handle a form submit using jquery and javascript. My JS $(document).ready(function () { $('#UnitFrom').submit(function (e) { alert();

Solution 1:

You should write:

 $('#UnitFrom').submit(function (e) {
    e.preventDefault(); // prevent default form submission
    alert('some'); // do some stuff
 });

OR

 $('#UnitFrom').submit(function () {
    alert('some');
    return false; // prevent form submission
 });

Solution 2:

Put something in your alert:

alert("TEXT HERE"); 

If you check your console, you should see an error similar to this:

Not enough arguments [nsIDOMWindow.alert]

When the exception is thrown, the method execution ends without calling preventDefault, allowing the form to submit. This is why it is a best practice to place preventDefault at the top of your function, but it is not required. If it is first and there is an exception, the default behavior is still prevented.


Solution 3:

Dude you can not have alert() first and than e.preventDefault();.

e.preventDefault(); has to be first and alert() second.

jsfiddle : http://jsfiddle.net/mpatm/


Post a Comment for "Jquery Submit(); Not Working For Firefox"