Using jquery to make a POST, how to properly supply 'data' parameter?

后端 未结 5 699
生来不讨喜
生来不讨喜 2020-11-30 11:01

I\'d like to make an ajax call as a POST, it\'s going to go to my servlet. I want to send parameterized data, like the following:

var mydata = \'param0=some_         


        
5条回答
  •  再見小時候
    2020-11-30 11:35

    You don't need to URL encode POST variables. However if you are interacting with a database, you will want to make sure your variables are injection attack protected.

    What you have will work, however as Vivin mentioned, if it's a form then the best way to do it is via .serialize().

    I use this a LOT personally for all my form submissions (done via .ajax()).

提交回复
热议问题