Simple question I can't seem to get right. I have a form #formOne
, I need to alert it's data. Something isn't working,
$("#formOne").submit(function(){
alert("you are submitting" + data);
)};
If not data
what do you use after +
?
Thanks!
Simple question I can't seem to get right. I have a form #formOne
, I need to alert it's data. Something isn't working,
$("#formOne").submit(function(){
alert("you are submitting" + data);
)};
If not data
what do you use after +
?
Thanks!
Share Improve this question edited Aug 14, 2018 at 16:14 informatik01 16.4k11 gold badges78 silver badges108 bronze badges asked Oct 5, 2010 at 2:37 Dirty Bird DesignDirty Bird Design 5,55313 gold badges67 silver badges127 bronze badges1 Answer
Reset to default 5You can use .serialize()
to see what the POST string looks like:
$("#formOne").submit(function(){
alert("you are submitting" + $(this).serialize());
});
Make sure that #formOne
is the form itself, so that this
refers to the <form>
element when serializing. For debugging you may always want to try this instead (using Firebug or Chrome):
$("#formOne").submit(function(){
console.log($(this).serializeArray());
});
This will print out as an array of objects with a name
and a value
property, a bit easier to read, at least to me.