如何解决编辑项目模式弹出窗口asp.net mvc 更新更新
我尝试使用以下示例:MVC 5 Edit Bootstrap Modal Popup
我有Index
页,在其中发送了onclickEdit(id)
页,还有Edit
页,其中放置了我的模式html。
.js:
{
var id = $(elem).data('assigned-id');
alert("1");
$.ajax({
url: '/Course/Edit/id=' + id,success: function (data) {
alert("2");
$('#modalWrapper').html(data);
$('#editModal').modal();
}
});
}
警报(“ 1”)有效,警报(“ 2”)无效。
控制器:
public IActionResult Edit(Guid id)
{
return PartialView(_courses.Find(id));
}
我检查了一下,我进入了Edit()
,它通过了,但是我没有成功实现ajax
我应该改变什么?
非常感谢
解决方法
好像您在'show'
函数中缺少字符串输入modal()
。通过添加它,它将使模态可见。
$('#editModal').modal('show');
Bootstrap文档: https://getbootstrap.com/docs/4.1/components/modal/#modalshow
更新
$.ajax({
url: '/Course/Edit/id=' + id,type: 'GET',cache: false,success: function (result) {
alert("2");
$('#modalWrapper').html(result);
$('#editModal').modal('show');
}
});
更新
您在Chrome浏览器的开发控制台中是否遇到任何错误?按F12即可访问它。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。