How to add more form fields and data to a serialized AJAX form in JQuery

In a jQuery form post, here is how you add more data to the serialized form data.  This is useful if you find yourself needing to pass some extra data along with the AJAX post.  This is a barebones example of a blind AJAX post to a form handler script called “form_handler.php”.

I find jQuery’s “serialize” and “serializeArray” functions are very efficient when collecting form data, you can’t get much easier than that.  The beauty of using a framework, whether it’s a Javascript framework, or PHP framework, these built-in libraries and functions save coding time.

I hope this saves someone time!  This solution works well in many different instances you have to post a form through Javascript.

– Aaron  Belchamber

Aaron Belchamber has written 243 articles

Leave a Reply

Your email address will not be published. Required fields are marked *