views:

36

answers:

3

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

+1  A: 

Use jQuery, and it's very easy:

$.post("/myactionpage.php",$("#formID").serialize(), function (data) { whatever(); });
Fosco
+1  A: 

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.

Unicron
A: 

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".

Organiccat