I would like to call a jquery ajax function and pass in data. I know the data is supposed to be formatted into a query string. If I pass in something like $(':checked') as the data then it will be formatted as tagname=value1&tagname=value2...etc which is good.
Now, I want to replace the jquery result with an associative array that has some integers in it i get value1=true$value2=true. That is not what I want.
How can I format the associative array with a key to pass into jquery ajax calls?
Ok, I’ve got one solution that I figured out. I created the following function which returns an array that can be passed in as data to jquery ajax function:
The trick is to use the .name and .value properties. I got the idea after reading the following jquery documentation:
If the object passed is in an Array, it must be an array of objects in the format returned by .serializeArray()
There’s probably a better way though. Please comment or provide another answer if you know.