【发布时间】:2016-03-05 22:20:59
【问题描述】:
我正在尝试使用 AJAX 加载模式的内容。这是我正在尝试做的代码 sn-p。
索引.cshtml
<button type="submit" class="btn btn-default" onclick="Create()">Create</button>
index.js
function AddTask() {
$Modal = $('#myModal')
$.get('/Customer/Create', function (data) {
$Modal.modal({ show: true });
});
}
客户控制器
public ActionResult Create()
{
return PartialView();
}
创建.cshtml
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>My modal content here…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button>
</div>
</div>
如何在模态中加载 Create.cshtml 内容?
【问题讨论】:
-
感谢您的意见,但没有奏效。它不能用作模态。
-
您在按钮上的
onclick事件中有Create(),但您要调用的函数名为AddTask- 这是您的问题中的错字,还是实际上是您的代码?
标签: jquery ajax twitter-bootstrap-3 asp.net-mvc-5