I am trying to load the contents of the modal using AJAX. Here is the code snippet what I am trying to do.
Index.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 });
});
}
Customer Controller
public ActionResult Create()
{
return PartialView();
}
Create.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>
How can I load the Create.cshtml contents in the modal?
Create()in theonclickevent on your button, but the function you want to call is namedAddTask- is that a typo in your question, or is that actually your code?