我正在Visual Studio中开发一个MVC项目c#。我有一个按钮触发模式。该按钮具有一个“ onclick”按钮,该按钮调用Ajax函数从模态HTML的控制器中的action方法中获取数据。当我在控制器中的action方法上设置断点时,模态弹出。当我删除断点时,它不起作用,chrome表示“ Unchecked runtime.lastError:消息端口在收到响应之前已关闭。”
//按钮中的onclick。
onclick="GetPersonel(@item.Id);
// @ section脚本中的ajax方法
function personelGetir(personelId) {
$.ajax({
type: "GET",
url: '@Url.Action("Update")?personelId=' + personelId,
success: function (data) {
$(".ModalUpdate").html(data);
}
});
//控制器中的动作方法
public ActionResult Update(int personelId)
{
var model = new PersonelSaveViewModel
{
Personel = _personelService.GetUserById(personelId),
};
return PartialView("_UpdatePartial", model);
}