jQuery query string traversal
javascript, jquery, query-string
Solution
this is my try.
var a = 'param1=2¶m2=1¶m3=5';
var b = a.split('&');
var final ={};
$.each(b, function(x,y){
var temp = y.split('=');
final[temp[0]] = temp[1];
});
console.log( final);
This returns an object like the dictionary that you needed:
{
param1 : "2",
param2 : "1",
param3 : "5",
}
Problem
Possible Duplicates: JavaScript query string get querystring with jQuery Is there an object/method in JavaScript to turn a string like this: `param1=2¶m2=1¶m3=5` into some sort of dictionary, so that I can refer to each element as `mystring['param1']` or `mystring[0]`? Can jQuery help here?