How to escape “&” ampersand character in form input using jQuery

后端 未结 5 1072
余生分开走
余生分开走 2020-12-30 06:00

I have a problem with my jQuery script that send data via POST method. The problem is whenever it sends data via Ajax that has an "&" ampersand in the sentence

5条回答
  •  自闭症患者
    2020-12-30 06:27

    You can use a native javascript escape() function

    In line 74

    data: : "&task_d=" + escape(task_d) + "" 
    

    Alternatively, you could enclose your query string values in quotes

    data: : "&task_d='" + task_d + "'" 
    

提交回复
热议问题