如何使用JavaScript加载部分视图

3

在我的看法中,我使用JavaScript来加载部分视图。

<p>
    <div id="AREA_PARTIAL_VIEW">

    </div>
</p>
<script type="text/javascript">
    $(document).ready(function ()
    {
        window.location.href = '@Url.Content("Insert", "Customers","Insert_Partial_View")';
    });
</script>

@using (Html.BeginForm(@MyChoise, "Corr_Exit"))
{
    @Html.AntiForgeryToken()

    <div class="panel-group">
        <div class="panel panel-primary">
               </html>     etc...........

我会把这个部分加载在<div>标签之间。
<div id="AREA_PARTIAL_VIEW">

</div>

但是我的代码不起作用。为什么呢?
有人可以帮我吗?

“不起作用”太过笼统。你是指什么?此外,你的代码将会重定向浏览器到你输入的URL。如果你想要加载某些内容,请使用jQuery的load函数... - Heretic Monkey
你认为 window.location.href = 是什么意思? - nurdyguy
1个回答

3
我已经使用了load ajax进行了这个操作。
$('#AREA_PARTIAL_VIEW').load('@Url.Action("Insert_Partial_View","Customers")');

你非常有帮助...!非常感谢你。 - Alan392

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接