javascript - jquery: spaces is added instead of %20 -


i have url (school.php/region%20division). when click anchor tag, should open page have url school.php/region%20division. of moment, page opens url school.php/region division. contains whitespace instead of %20. should keep %20? in advance.

here code

var url=escape("school.php/"+region+' '+division); //school.php/region%20/division $("a.searchlink").html("<a href="+url+">click here</a>"); 

you can use encodeuri(uri) function in javascript

for eg:

<script>  var uri="school.php/region%20division"; document.write(encodeuri(uri)+ "<br>");  </script> 

answer

school.php/region%2520division 

and use it... have encode %20 in url ll give desired output


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -