How can I include special characters in query strings?

后端 未结 7 1002
日久生厌
日久生厌 2020-12-09 15:22

URL http://localhost/mysite/mypage?param=123 works fine. However, if I want to put some special characters in param, like ?, /

7条回答
  •  感动是毒
    2020-12-09 16:10

    I did below, it works fine.

    const myQueryParamValue = "You&Me";
    const ajaxUrl = "www.example.com/api?searchText="+encodeURIComponent(myQueryParamValue)
    

提交回复
热议问题