Can I add elements of two forms by using .serializeArray() function of Javascript
Question by user1254174
I have a Web Page which contains 3 forms. Each one has a large list of elements ( Input, select).
We were using query string to update the page on user submit using the serialize function and passing the params in the URL. In one such case, the length of the URL has crossed the maximum allowed string length in IE browser.
Now I am planning to change that to POST method and also send the elements using Jquery serializeArray function as the Server expected the data to be in form of an Array.
I am not able to find sufficient data on .serializeArray() function.
Can the output of the .serializeArray() function for each form in my page be combined and then submitted ?
Is there any other method by which I can do this?.
Any suggestions is welcomed.
Answer by Starx
You can combine the serialized data in an array and send
var data = new Array();
data[] = $("formone").serialize();
data[] = $("anotherform").serializa();
$.post("toapage.php", { formdatas : data }, function(msg) {
alert(msg); //on success
});