Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  126] [ 2]  / answers: 1 / hits: 157220  / 14 Years ago, thu, july 22, 2010, 12:00:00

I'm trying to find information on how to serialize an object to query string format, but all my searches are drowning in results on how to go the other way (string/form/whatever to JSON).



I have



{ one: 'first', two: 'second' }


and I want



?one=first&two=second


Is there a good way to do this? I don't mind plugins or whatnots - if the code I find is not a plugin, I'll probably re-write it to one anyway...


More From » jquery

 Answers
15

You want $.param(): http://api.jquery.com/jQuery.param/



Specifically, you want this:



var data = { one: 'first', two: 'second' };
var result = $.param(data);


When given something like this:



{a: 1, b : 23, c : te!@#st}


$.param will return this:



a=1&b=23&c=te!%40%23st

[#96149] Monday, July 19, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gregoriocoya

Total Points: 549
Total Questions: 111
Total Answers: 104

Location: Saint Helena
Member since Mon, Jan 16, 2023
1 Year ago
;