当按钮单击时,我将其重定向到sendData函数并发送一个ID
<button type="button" onclick="sendData(@sefer.ID)">
但是当我执行Ajax操作时,出现开机自检错误。我发送到控制器的数据正确发送,但视图屏幕没有打开。
function sendData(seferId) {
console.log(array);
$.ajax({
url: 'Rezervasyon/Index',
type: 'POST',
contentType: "application/json; charset=utf-8",
data: { seferId: seferId, selectedData: array },
success: function (data) {
console.log(data)
},
error: function (err) {
alertify.error('Error');
}
});
}
顺便说一句我的控制器
[HttpPost]
public IActionResult Index(string seferId, List<PostData> selectedData)
{
MusteriViewModel model = new MusteriViewModel
{
SeferId = seferId,
SelectedData = selectedData
};
return View(model);
}