append variable to be posted to ajax serialized data

后端 未结 1 1308
栀梦
栀梦 2021-01-21 06:45

I have a form that I can post all the data in the ajax call like this:

data: $(\"#myform).serialize(),

But in the function, I set a variable to

相关标签:
1条回答
  • 2021-01-21 06:56

    The serialize() method return a parameter string, so you could just use string concatenation like

    data: $("#myform").serialize() + '&favorite=' + favorite
    
    0 讨论(0)
提交回复
热议问题