I am looking for a similar urlencode() function from PHP only in JavaScript. JQuery library is allowed.
urlencode()
Basically, I need to encode a string and then redirect the user to another page only using JavaScript.
There is no function that fully matches urlencode() , but there is one equivalent to rawurlencode() : encodeURIComponent() .
rawurlencode()
encodeURIComponent()
Usage: var encoded = encodeURIComponent(str);
var encoded = encodeURIComponent(str);
Here you can find the link:
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent
Take a look at phpjs.org if you are looking for a JS function equivalent to PHP:
http://phpjs.org/functions/urlencodeโ73
Here you can use encodeURIComponent() (with some changes).
encodeURIComponent ()http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp
Try urlencode from http://locutus.io/php/url/urlencode/ . I tested it on several occasions when it worked, and it worked.