Escaping jQuery data being sent via POST

前端 未结 3 487
醉梦人生
醉梦人生 2020-12-08 21:49

I\'m using jQuery.ajax to extract form data from a page, and send it to my database (via another PHP page).

The form information is collected by:

var         


        
3条回答
  •  遥遥无期
    2020-12-08 22:10

    encodeURIComponent will do what you are looking for.

    var X = encodeURIComponent($('#div1').val());
    var Y = encodeURIComponent($('#div2').val());
    

    This will encode all potentially insecure characters.

提交回复
热议问题