Possible Duplicate:
How can I get query string values?
I Have this link
url/merchant.html?id=45
I am trying to get the ID using JS or JQuery with no luck.
I tried this code
var urlParams = {};
(function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
it returns "undefined"
What is the problem with the code?