Inserting Hebrew text from thre querystring into a field value

I am using the following code to take the value of a query string parameter, and insert it as a value of a field, but its coming out weirdly parsed.

URL with the query string: activities.html?t=שלום

Value of field comes out: %D7%A9%D7%9C%D7%95%D7%9D, (Whereas it should be: שלום.)

Code:

// access parameter using function below
var title = getUrlVars()["t"];   

// insert value into field: 
if (title) {
    $("#pdesc").val(title);
}


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;
}   

1 answer

  • answered 2018-01-11 20:51 Yossi

    Try to use decodeURI() on your result, it should work.