Hi,

I believe you can post form either using $.post  or $.ajax method and
there's a function called serialize( ), which serializes form data,
instead of typing it's data in key value pairs manually.

Serialize:
http://docs.jquery.com/Ajax/serialize


$.post and $.ajax:

http://docs.jquery.com/Post
http://docs.jquery.com/Ajax/jQuery.ajax

Rough example:

Suppose, you have an HTML form:

<form name="testForm" id="testForm" action="process.php"
method="post">
Name: <input type="text" name="f_name" value="" /> <br />
Email: <input type="text" name="f_email" value="" /> <br />
....
<input type="submit" name="submit" value="Submit" />
</form>


When posting via form submission, using $.post method:

$("#testForm").submit(function() {
     // do validation.. if you want and then post it.
      $.post("process.php", $(this).serialize(), function(data) {
                alert( data ) ; /// alert data from server, or do something else
        });
       return false;
});

You can also use $.ajax instead of $.post method. I hope it helps,

Thanks,
Abdullah



On Mar 29, 4:34 am, iceangel89 <iceange...@gmail.com> wrote:
> how can i post a form to server using jquery?
>
> $.post requires me to post data in key value pairs. if the form is big
> then that's a bit tedious. any better way?

Reply via email to