Convert POST Fields to Objects in jQuery

Posted on September 29, 2019 at 4:46 pm

Here is a simple function to convert POST fields to object:

function postArray(form){ var data = {}; form = $(form).serializeArray(); for(var i in form) data[form[i].name] = form[i].value; return data; }

You can use it like this:

data: postArray("#form-id"),

Receive updates via email

Other Posts

Updated Posts