Need help..how can I get the parameter pass by the ajax..
url: test.htm?a=1&b=2&c=3
I want to get the value of b.
Need help..how can I get the parameter pass by the ajax..
url: test.htm?a=1&b=2&c=3
I want to get the value of b.
function getQueryString(queryString) {
var result = {},
re = /([^&=]+)=([^&]*)/g, m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
}
var query = "test.htm?a=1&b=2&c=3"
var myParam = getQueryString(query)["b"];
alert(myParam);
the "dirty" way is to location.search.split("&b=")[1].split("&")[0];
but that's not reusable and I'll get flamed about it for sure...
the better way has been answered here before: https://stackoverflow.com/a/2091331/1238884