I have a jQuery array and I want to use it in an AJAX call with my PHP script, can anyone help me do this?
var things = {
"foo": ["bar", "baz"],
"bar": 1234
};
var output = "?foo[]=bar&foo[]=baz&bar=1234";
Thanks!!
I have a jQuery array and I want to use it in an AJAX call with my PHP script, can anyone help me do this?
var things = {
"foo": ["bar", "baz"],
"bar": 1234
};
var output = "?foo[]=bar&foo[]=baz&bar=1234";
Thanks!!
$.param(myobj, true)
From the manual:
As of jQuery 1.4, the $.param() method serializes deep objects recursively to accommodate modern scripting languages and frameworks such as PHP and Ruby on Rails. You can disable this functionality globally by setting jQuery.ajaxSettings.traditional = true;.
As of jQuery 1.8, the $.param() method no longer uses jQuery.ajaxSettings.traditional as its default setting and will default to false. For best compatibility across versions, call $.param() with an explicit value for the second argument and do not use defaults.