我想以字符串格式访问发布到Controller操作的数组,
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
}
})
以字符串格式发布,如
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"}]
在Controller内部,我想访问这些数据,比如,
public ActionResult Passenger_Create([DataSourceRequest] DataSourceRequest request, IEnumerable<PassengerViewModel> models)
但它无法访问。请尽快帮助我。