单击表时,部分视图未被Javascript加载

时间:2016-09-28 05:15:04

标签: javascript asp.net-mvc view partial-views

我有一张表,点击后,应该加载局部视图。我在Controller的ActionResult RetrieveItemPrice()中放了一个断点,它成功转到return语句,但它没有在我的View中显示PartialView。

Controller(ItemController)

public ActionResult RetrieveItemPrice()
{
    return PartialView("~/Views/Item/_ViewItemPrice");
}

查看(创建)

...
<div class="col-sm-8" style="border: 0px solid green; padding:10px;">
    <div id="pvItemPrice" class="" style="border: 0px solid green; ">
    </div>
</div>
...
<script type="text/javascript">
    $(document).ready(function () {
        $("#dbTable").click(function (e) {
            debugger;
            $("#pvItemPrice").load('/Item/RetrieveItemPrice');
        });
    });
</script>

PartialView(_ViewItemPrice)

@model CDS.Models.ItemViewModel
@using PagedList.Mvc;

<div>
    <table id="dbTable2" class="table table-hover" aria-busy="false">
        <thead>
            <tr class="inner-table-head">
                <th class="hidden">
                    @Html.DisplayNameFor(model => model.itemId)
                </th>
                <th>
                    @Html.ActionLink("Item", "Create", new { currentFilter = ViewBag.CurrentFilter })
                </th>
                <th>
                    @Html.ActionLink("Price", "Create", new { currentFilter = ViewBag.CurrentFilter })
                </th>
            </tr>
        </thead>
        <tbody id="dbBody2">
            @foreach (var item in Model.Items)
            {
                <tr>
                    <td class="hidden">
                        @Html.DisplayFor(modelItem => item.itemid)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.itemdesc)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.itemprice)
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

1 个答案:

答案 0 :(得分:0)

传递给视图的模型在哪里(CDS.Models.ItemViewModel)?

return PartialView("~/Views/Item/_ViewItemPrice");

此外,网络工具作为响应显示了什么? 200或500响应代码?