Add Element to .serializeArray

var form = $('#form'); //considerate disabled fields in array var disabled = form.find(':input:disabled').removeAttr('disabled'); //like a [name: "n_modelo" value: "1250"] .. , Object... var form_detalles = form.serializeArray(); //i want add next values var jsonArray = [{ 'name': "other_external_field", 'value': 1250 },{ 'name': "test", 'value': "mariobustosjmz" }]; form_detalles = form_detalles.concat(jsonArray); dataObj = {}; //tmp $(form_detalles).each(function(i, field) { dataObj[field.name] = field.value; }); //new array with new values console.info(form_detalles);
When i want save a form i serializearray send to ajax like arrayjson, but , sometimes i need add other values that no are inside the form . Is when "concatenate" other values before send it.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.