行动代码是:
//tickets is null in chrome but has value in IE
public async Task<IActionResult> ChangeStatus(string tickets)
{
//Code goes here
}
ajax call
var selectTickets = '"ticket1","ticket2"'
$.ajax
({
type: 'post',
url: "/SkyBusTickets/ChangeStatus/",
data: {'tickets': selectTickets},
success: unexpiredTicketsBulkStatusChangeSuccess,
failure: unexpiredTicketsBulkStatusChangeError
});
在Chrome中,它在控制台中出现错误
jquery.js:9536 POST http://localhost:54656/SkyBusTickets/ChangeStatus/ 500(内部服务器错误)
需要做些什么才能使它在两种浏览器中都有效?
修改
如果我将操作方法更改为以下操作方法,它也将停止在IE中工作
//tickets is null in both chrome & IE
public async Task<IActionResult> ChangeStatus([FromBody]string tickets)
{
//Code goes here
}
答案 0 :(得分:0)
检查一下,它对我有用
//ajax side
$(document).ready(function () {
var selectTickets = '"ticket1","ticket2"'
$.ajax
({
type: 'post',
url: "api/Test/ChangeStatus",
dataType: 'json',
data: { "": selectTickets },
success: function () {
},
failure: function () {
}
});
});
在控制器部分
[HttpPost]
public string ChangeStatus([FromBody]string tickets)
{
return "sdfdf";
}