0
我从ajax函数调用一个动作,获取我的ViewModel,然后尝试打开与其他ViewModel的新视图,但redirectToAction和返回视图不工作。其他答案我看到的只是得到了打开其他视图,而不与它发送的ViewModelajax调用后返回视图与ViewModel
Ajax调用
$("#delete").click(function() {
var model = $("#forma").serialize();
console.log("delete", model);
$.ajax({
url: '@Url.Action("DeleteDevices", "package")',
contentType: 'application/json; charset=utf-8',
dataType: "json",
data: model,
success: function (result) {
}
});
return false;
});
和contorller它什么都不做
public ActionResult DeleteDevices(PackageDevicesViewModel viewModel)
{
//model processing here
return View(NewModel);
}
删除'contentType:'application/json; charset = utf-8','并更改'dataType:'html''(或者删除它) - 你没有返回'json' –
我建议这应该是一个POST而不是GET(名字方法建议您修改数据) –
您在控制台窗口中看到了什么错误, –