When submitting a form using post, what if I dont want it serialized (or going as a string, which i feel is not safe) and want it to be submitted the same way as it would be if I wasn’t using jquery? How could I do that?
$.ajax({
type: "POST",
data: $("#sform").serialize(), //don't want to use this part. Want it go just like it would without using jquery
Is this data: something that “has to be” used? What are the alternatives to this?
That’s exactly what the
.serialize()method does 🙂 It formats the form data usingapplication/x-www-form-urlencodedencoding which is the default format for html forms. So if you want the server to receive the data in exactly the same format as if you were not using javascript, then use the.serialize()method.The standard method to AJAXify a form is the following:
Now whether the user has javascript disabled or not, the server will receive the form POST in exactly the same way.