Just another WordPress site

Serialize form data using jQuery

Serialize form data using jQuery helps in getting form element data easy.

function getFormData(form) {
var rawJson = form.serializeArray();
var model = {};

$.map(rawJson, function (n, i) {
    model[n['name']] = n['value'];
});

return model;
}

Now use model object to get your form elements value. like model.name

The post Serialize form data using jQuery appeared first on Santosh Shah.


Leave a Reply

Your email address will not be published. Required fields are marked *