Having multiple formcollection passed through parameter in ajax call

34 Views Asked by At

I am doing an ajax call where I serialize two forms but when passing the data in only the 2nd forms' key and value is showing up for both parameters, is there a better way to do this or am I missing something?

        var form1 = $('#form1').serialize();
        var form2 = $('#form2').serialize();

        $.ajax({
            url: "/Controller/PassForm",
            type: 'POST',
            data: { form1:form1, form2:form2},
            dataType: 'json',
            success: function (data) {
                //console.log(data); 


            }
        });

Controller

public JsonResult PassForm(FormCollection form1, FormCollection form2){
...}
0

There are 0 best solutions below