jQuery.param()
S2C Home « Ajax « jQuery.param()
Serialized array/object representation.
Description
The jQuery.param()
Ajax method, allows us to create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
Shorthand version $.param()
- The
jQuery.param()
method is used internally to convert form element values into a serialized string representation when using the.serialize()
method.
Syntax
Signature | Description |
---|---|
jQuery.param( object ) | Perform an asynchronous HTTP (Ajax) request to be sent to the specified url, optionally passing some request settings.
|
Parameters
Parameter | Description | Type |
---|---|---|
object | An array or object to serialize. | Array orPlainObject |
Return
A String
object.
jQuery.param( object )
ExampleTop
Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
In the example below when we press the button the first time we create a serialized representation of an object. For the example we output messages for this and also for the object decoded. The resultant string could just as easily be sent to a server as part of an Ajax request.
$(function(){
$('#btn1').one('click', function(){
var obj1 = {species: 'penguin', skills: {flight: 'no', swim: 'yes'}, climate: 'cold'};
$('#div3').append($.param(obj1) + '<br>');
$('#div3').append(decodeURIComponent($.param(obj1)) + '<br>');
return false;
});
;});
div3. Some initial text.
Related Tutorials
jQuery Advanced Tutorials - Lesson 10 - Ajax Helper Functions