A. Dubey A. Dubey - 2 months ago 22
ASP.NET (C#) Question

How to replace in jQuery asp.net

I have this

function show()
{
var d = "myform.htm?pass=" + pass+ "&name=" + name;
window.location.href = d;
}


And on next webform,

function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}


Now when I call

var b = getUrlVars()["name"];


It shows

I%20am%20a%20male


It is because it contains space

I tried but not able to get that "what should I write there in
getUrlVars()
"

Answer

To decode use:

vars[hash[0]] = decodeURIComponent(hash[1]);