form submission and JQuery
I was working on an html form today, and I learned that keeping the "action" attribute empty woud result in calling the URL of the current page. I noticed that when I use the JQuery "live()" event handler on the submit button of the form, the normal POST request is not made. I want to make sure I understand the sequen开发者_StackOverflow中文版ce of events; in particular how does the non-ajax POST request depend on the click of the submit button?
The POST request is generated by the form submitting.
The stuff that happens when the form submits is defined by the <form>
tag.
The submit button is one way of causing the form to submit.
Getting a little more in-depth, it's possible to submit the form with (among other things)
$('form').submit(); // You can select form different, for example form#SomeID and form.someClass
By default, if you just allow the submit button to run on its own without modifying it with with jQuery, it will tell the form to submit.
As such, by default, all the submit button will do is call (essentially)
$(this).getParentForm().submit(); // This is totally madeup code, but you get the idea
Anything past this point gets to the point where I can't deny that it's just lying about how things work in order to give you an idea of what they do.
jQuery requires the url of the page where it will submit the form.
精彩评论