Javascript redirect and wrong special chars encoding

154 views Asked by At

I have this code to perform searches in my site:

var encoded = encodeURIComponent($("#searchBar").val());
location.href = sitePath + "/search/keyword/" + encoded;

Because i'm italian I use a lot chars like à è ù, but when I put them in search3w they're not correctly encoded.

If i try to console log encoded var it will print correctly encoded chars for URLs, but when the script does the effective redirect to te page i have things like http://www.mysite.it/search/à and chars are not well received.

1

There are 1 answers

1
dan8912 On

I think there can be a problem with encodeURIComponent function. Did you used firebug for debugging?

Regards, dan8912