Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  133] [ 7]  / answers: 1 / hits: 20447  / 13 Years ago, wed, march 23, 2011, 12:00:00

I have a javascript variable which is a dictionary of key-values pairs of querystring. I need to again convert this dictionary into a query string. I am using jquery.param functin but it takes either an array or an object. How can I convert my dictinoary variable to array/object which jquery.params can accept.



Tried using serializeArray but it does not work.


More From » jquery

 Answers
9

The jQuery.param method can take an array i in this form:



[{ name: 'asdf', value: '42' },{ name: 'qwerty', value: '1337' }]


If your dictionary have other property names, you can use the jQuery.map method to convert it. Example:



arr = $.map(arr, function(e){
return { name: e.key, value: e.val };
});

[#93118] Tuesday, March 22, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
noe

Total Points: 149
Total Questions: 91
Total Answers: 91

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
;