JQuery serialize method

JQuery provides a method called serialize, which takes all your form data and converts it into a URL-encoded string.

So, if you want to submit all your form data via ajax, you would call the serialize method, like so:

formData = $(‘form’).serialize();

With this convention, the formData value would be something like:

userName=richie&city=oakland&favoriteColor=blue

Now, you can simply send this data to the server with a statement like:

$.post(‘/formPagel’,formData);

Check out the JQuery API for more info:

http://api.jquery.com/jQuery.post/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s