Importance of serialize() in ajax() Method
When I use this method in one of my functions to communicate with the server, for some reason it would work when I took out the "serialize" portion of the function.
For instance, I have this:
- $("form").submit(function(event) {
- var $form = $(this);
- var $inputs = $form.find("input, select, button, textarea");
- var serializedData = $form.serialize();
- $.ajax( {
- url: "some url",
- type: "post",
- data: serializedData;
- dataType: 'json'
- }).done(function (data) {
- //some code
- });
- });
When I take out the "data" parameter in the ajax method and rid of the serializeData variable, it doesn't work. Why is that? What is the importance of the serialize data part of this? Doesn't "post" already grab the necessary form values for me?