Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

escape & in url

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

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

But nothing is working.

If anyone has idea please share with me.

Thanks

like image 314
alienavatar Avatar asked Dec 22 '22 02:12

alienavatar


1 Answers

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

like image 53
Justin Ethier Avatar answered Jan 15 '23 16:01

Justin Ethier