merbjedi/jquery_better_param
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
jQuery Better Param
===================
This jQuery plugin overwrites the default jQuery.param method, extending it to allow nested objects,
and convert them to be easily passed as parameters over HTTP.
examples:
$.param({
"categories": {
id: 1,
name: "Cat1"
}
});
//=> "categories[id]=1&categories[name]=Cat1" (unescaped)
$.param({
"categories[]": [
{id: 1, name: "Cat1"},
{id: 2, name: "Cat2"}
]
});
//=> "categories[][id]=1&categories[][name]=Cat1&categories[][id]=2&categories[][name]=Cat2" (unescaped)
even hugely complex object structures work fine:
//try this one out...
$.param({
"person": {
name: "Joe Blow",
address: "51 Westinghouse Ave",
"categories[]": [
{id: 1, name: "cat1"},
{id: 2, name: "cat2"}
]
}
});
Running the Tests:
===================
$ git clone git://github.com/merbjedi/jquery_better_param.git
$ cd jquery_better_param/test
$ open index.html
About this Plugin:
===================
This plugin is meant as a demonstration of a pending patch to jQuery 1.3.3. The patch has been applied as of rev 6534 of the official jQuery repository and should appear in jQuery 1.3.3 once its out.
This plugin is tested and is safe for use within jQuery 1.3.2 only. Any other jQuery versions, I'd suggest running the included unit tests to verify that its functional.