I am attempting to have the partial view HTML append to the content of a Modal-popup box. The script provided below is meant to execute the "Details" action when a button is clicked and return the HTML output to the success callback. Although the ActionMethod runs, I am unable to retrieve the corresponding view back as a parameter - the alert does not show up! Can you identify any issues in this script? What could be the reason why I am unable to obtain the view back?
<!--language: lang-js-->
<script>
$(".detail-link").click(function () {
var Did = $(this).data("id");
$.ajax({
type: 'POST',
url: "/Home/Details/",
data: { id: Did },
dataType: 'html',
success: function myfunction(data){
alert(data);
}
});
});
</script>
This is an action method called "Details"
<!--language: lang-cs-->
[HttpPost]
public ActionResult Details(int? id)
{
HomeModel model = new HomeModel();
var book = db.Books.Where(b => b.Id == id).Include(b => b.Author).SingleOrDefault();
if (book == null)
{
HttpNotFound();
}
book.DisplayNumber++;
db.SaveChanges();
model.bookDetails = book;
return PartialView(model);
}
If needed, I can also provide the view that I am trying to receive back.