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 be be posted
That variable is var favorite = true; or var favorite = false;
It will post that variable if I do this:
var favorite = true;
var first_name = $("myform input[name=first_name]").val();
data: { favorite: favorite, first_name: first_name, etc ... }
But I was wondering if i could something like:
data: $("#myform).serialize + {favorite: favorite}
Its not a big deal if thats not possible, I am just clean up the function.
The serialize() method return a parameter string, so you could just use string concatenation like
data: $("#myform").serialize() + '&favorite=' + favorite
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With