Is it posible with ajax to send one json-array (array with json objects) and also include a separate parameter to receive in MVC action method?

Posted by david2342 on Stack Overflow See other posts from Stack Overflow or by david2342
Published on 2013-10-18T09:50:48Z Indexed on 2013/10/18 9:54 UTC
Read the original article Hit count: 140

Filed under:
|
|

Is it posible with ajax to send one json-array (array with json objects) and also include a separate parameter to receive in MVC action method?

var n = { number: 1
};

    $.ajax({
        type: "POST",
        url: url,
        contentType: "application/json; charset=utf-8",
        dataType: "html",
        data: JSON.stringify({jsonObjects:json, number:n}),
        success: function (response) {
            $('#body').html(response)
        }

        }
    });

public ActionResult Create(List jsonObjects, int? number)

JsonObjects is comming in like it supposed to but number is null.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON