我将一些值传递给 MVC 控制器,它正在返回 json 值。现在的问题是控制器端,值正确返回但是当我在 jquery 中检查它时,它显示未定义的数据。
控制器代码:
[HttpPost]
[Authorize]
public ActionResult DeleteServices(List<Int32> serMapId)
{
int success = -1;
if (serMapId.Count > 0 )
{
int count = RequestDL.DelServices(serMapId);
if (count > 0)
{
success = count;
}
}
return Json(new { success });
}
Jquery Ajax 脚本:
$.ajax({
url: "/CRM/DeleteServices",
type: "POST",
data: postData,
success: function (result) {
alert(result.success);
if (result.success > 0) {
alert("Service(s) deleted successfully");
}
else {
alert("Service(s) not deleted successfully");
}
},
error: function () {
alert("Something goes wrong at server side.");
}
});
先感谢您。