AJAX Submit via Post entire Form
I am trying to simply post an entire form w/o the need to create the url like you would have to in a get call. All of the tutorials I have seen for this for some reason create a parameter URL and send it via the开发者_如何学Python send ability. I want to be able to send a form via the form id or form name, is this possible? The reason is because I will have some submits that can have anywhere from 2 to 1000 checkboxes the user can press (not my choice). Example I looked at mainly is: http://www.captain.at/howto-ajax-form-post-request.php
I use a type="button" to do the submit not a onchange or anything like that.
Use jQuery, and it's very easy:
$.post("/myactionpage.php",$("#formID").serialize(), function (data) { whatever(); });
If you can use jQuery, the JQuery Form plugin does exactly that.
The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process.
There are multiple ways to do this and you're right, you don't want to use the GET method. You want to use the POST method, which allows you to send all the data in the form. There are too many options to list, but jQuery is a good start. If you don't want to use an external library like jQuery, try checking out a google search on "ajax via post".
精彩评论