Jquery .Submit() is not triggering submit event

2019-06-28 03:50发布

问题:

I have a very small problem,

I want to submit my code using jquery on dropdown change:

 $("#mydropDown").change(function(){           
        $("#myForm").submit();
    });

but it is not submitting.

I also fired following code in firebug console:

$("#myForm").submit();

it given me this output

[form#myForm]

I'm not getting what is the problem... :o?

回答1:

May be, you have another event bound, if want cleaning up:

 $("#mydropDown").change(function(){           
        $("#myForm").unbind().submit();
    });

make sure that is within

$(document).ready(function(){
  //....
})


回答2:

hi that time I used unbind but I really wanted to find to why it is happening. later I found answer of this question. I'm not much sure it is correct or not but it worked for me. In the same form ('#myForm') there is a submit button with id='submit' and name='submit'. I changed both to submit_btn and it worked for me hope it may help...

Thank you for your support!!!



回答3:

You may have another event bound to your form that is cancelling the submit event.

To check this, you could execute the following in the console:

console.log($('#myForm').data('events'));

Which will output all events bound to your form.



回答4:

The jquery is pretty basic so it must be something else. To debug this I would just comment out all the jquery and see if you can get the form to submit with just a submit button.

If that doesnt work it would look at your action page.