Escaping ampersand in URL

前端 未结 8 1299
余生分开走
余生分开走 2020-11-22 03:25

I am trying to send a GET message that contains strings with ampersands and can\'t figure how to escape the ampersand in the URL.

Example:

http://www         


        
8条回答
  •  感情败类
    2020-11-22 03:40

    They need to be percent-encoded:

    > encodeURIComponent('&')
    "%26"
    

    So in your case, the URL would look like:

    http://www.mysite.com?candy_name=M%26M
    

提交回复
热议问题