Ajax and Forms

Contact Us or call 1-877-932-8228
Ajax and Forms

Ajax and Forms

jQuery's Ajax capabilities can be especially useful when dealing with forms. The jQuery Form Plugin is a well-tested tool for adding Ajax capabilities to forms, and you should generally use it for handling forms with Ajax rather than trying to roll your own solution for anything remotely complex. That said, there are two jQuery methods you should know that relate to form processing in jQuery: $.fn.serialize and $.fn.serializeArray.

Turning Form Data into a Query String

$('#myForm').serialize();

Creating an Array of Objects Containing Form Data

$('#myForm').serializeArray();

// creates a structure like this:
[
	{ name : 'field1', value : 123 },
	{ name : 'field2', value : 'hello world' }
]
Next