Escape & in url

How can I avoid & (ampersand) in the url with the correct replacement in jQuery function. I tried

 .replace("/&/g", "&") .replace("/&/g", "%26") .replace("/&/g", "\&") 

But nothing works.

If anyone has an idea, please share with me.

thanks

+4
source share
2 answers

If you just need to escape the URL, I recommend using a JavaScript function such as encodeURIComponent .

+9
source
+2
source

Source: https://habr.com/ru/post/1313424/


All Articles