【问题标题】:How load Partial View with JavaScript [duplicate]如何使用 JavaScript 加载局部视图 [重复]
【发布时间】:2018-03-01 16:44:08
【问题描述】:

在我看来,我有 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...........

我会在&lt;div&gt; 标签之间加载这个部分

<div id="AREA_PARTIAL_VIEW">

</div>

但我的代码不起作用。为什么?

有人可以帮帮我吗?

【问题讨论】:

  • “不起作用”非常广泛。你什么意思?此外,您的代码会将浏览器重定向到您输入的 URL。如果你想加载一些东西,使用jQuery的load函数...
  • 你认为window.location.href = 会做什么?

标签: javascript asp.net-mvc razor


【解决方案1】:

我为此使用了加载 ajax

$('#AREA_PARTIAL_VIEW').load('@Url.Action("Insert_Partial_View","Customers")');

【讨论】:

  • 你帮了大忙……!非常感谢..
猜你喜欢
  • 2011-11-11
  • 2013-01-03
  • 2012-11-10
  • 2011-11-09
  • 2022-01-02
  • 1970-01-01
  • 2017-10-31
  • 2021-08-13
  • 1970-01-01
相关资源
最近更新 更多