Jquery .Submit() is not triggering submit event

2019-06-28 03:36发布

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?

4条回答
你好瞎i
2楼-- · 2019-06-28 04:17

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!!!

查看更多
倾城 Initia
3楼-- · 2019-06-28 04:21

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.

查看更多
【Aperson】
4楼-- · 2019-06-28 04:24

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(){
  //....
})
查看更多
我只想做你的唯一
5楼-- · 2019-06-28 04:26

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.

查看更多
登录 后发表回答