I am trying to implement an Ajax way to update my data grid. So far I have coded the following in my controller:
public ActionResult Detail(string ac, string me) {
vm.AdminDetails = _link.Detail(ac + me).ToList();
if (Request.IsAjaxRequest())
return PartialView(vm);
return View(vm);
}
My snapshot of the view looks like this:
@model ViewModels.Shared.BaseViewModel
@{
Layout = "~/Areas/Administration/Views/Menus/_Layout.cshtml";
}
@section content {
<div class="bdy_box">
<div id="detailData" class="rep_tb0">
// code to generate the list of data
</div>
</div>
My snapshot of the javascript looks like this:
function reload(entity, pk) {
$.ajax({
url: "/Administration/" + entity + "s/Detail",
data: { pk: pk },
dataType: 'html',
cache: false,
success: function (responseText) {
$('#detailData').html(responseText);
}
});
};
The data does get returned BUT my problem is other data also gets returned. When I look at the contents of the detailData div I see much more than I need. For example I see something like the following:
<div class="rep_tb0" id="detailData">
<title></title>
<meta content="" name="title">
<meta content="" name="description">
<meta content="" name="keywords">
<link type="image/x-icon" href="/Content/Favicons/default.ico" rel="shortcut icon">
<link type="text/css" rel="stylesheet" href="/Content/Stylesheets/Style203.css">
Is there a reason why it’s showing me all this and how can I stop it showing all this header type of information?
Melissa,
I’m assuming that you have a partialview called
_detail.cshtml(if not, you need to create one)??I believe that you may be actually invoking the ‘full’ view detail.cshtml based on your sample. I’d suggest that you call your action it along the following lines: