tags:

views:

57

answers:

3

Hello I want to serialize and unserialize a form with jquery But I don't know how to get all attributes of all elements in a serialized way? please anyone help thankyou......

+1  A: 

jQuery has a serialize function.

$("#form").serialize(); // Returns serialized string

Reference: http://api.jquery.com/serialize/

Pekka
A: 

All elements in the form will be sent along if using the $('form').serialize();

nillls
+1  A: 

.serialize() will map your input controls that have a name attribute defined into a standard query string:

foo=bar&bar=foo&and=soon

That kind of string is easy accesible in almost every "backend" programming language.

If you need to serialize object information, use JSON.

var obj = {
    foo:  'bar',
    more: 'etc
};

serialize this with window.JSON.stringify(obj);. To unserialize such a JSON string, use window.JSON.parse(str);, which returns a javascript object.

Many languages support this principle.

jAndy
hi there, why do jquery use name attribute to serialize a form (instead of using id attribute?)
frabiacca