0

I want to access the Array posted to the Controller's action in stringified format as,

for (var i = 0; i < passengers.length; i++) {
                var tmp = passengers[i].split(",");

                    datasource.insert({ PassengerID: 0, PassengerName: tmp[0], ID: tmp[1], Type: "Adult" });
                    models.push({ PassengerName: tmp[0], ID: tmp[1], PassengerType: "Adult" })
            }

            $.ajax({
                type: 'POST',
                url: '/Document/Passenger_Create',
                data: { models: JSON.stringify(models) },
                success: function (data) {

                    datasource.data
                }
            })

which is posted in Stringified format like,

models:[{"PassengerName":"test1","ID":" testing","PassengerType":" 123"},{"PassengerName":"test2","ID":" testing","PassengerType":" 123"},{"PassengerName":"test3","ID":" testing","PassengerType":" 123"},{"PassengerName":"test4","ID":" testing","PassengerType":" 123"},{"PassengerName":"test5","ID":" testing","PassengerType":" 123"}]

And inside of Controller I want to access those data Like ,

public ActionResult Passenger_Create([DataSourceRequest] DataSourceRequest request, IEnumerable<PassengerViewModel> models)

But it is not accessible. Please help me on this ASAP.

4

0 回答 0