[英]refresh Partial View after ajax call
I have PartialView in Shared Folder OF my Mvc Project now I want After my Ajax call this Partial Be refresh.I use this: 我现在在Mvc项目的共享文件夹中有PartialView,我想要在Ajax称为Partial Be refresh之后使用。
$('#Footer').load('/Views/_FooterReport.cshtml'); $('#Footer')。load('/ Views / _FooterReport.cshtml'); and i get this error: 我得到这个错误:
GET http://localhost:2885/Views/_FooterReport.cshtml 500 (Internal Server Error) GET http:// localhost:2885 / Views / _FooterReport.cshtml 500(内部服务器错误)
<div id="updateAjax">
some Table
</div>
<div class="btnContainer">
some button here
</div>
<div id="Footer">
@Html.Partial("_FooterReport")
</div>
$.ajax({
url: url,
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: "html",
traditional: true,
data: parameters,
success: function (data, textStatus, jqXHR) {
$('#updateAjax').html(data);
//here How Can I Refresh or Reload my Partial in Footer
('#Footer').load('/Views/_FooterReport.cshtml'); ('#Footer')。load('/ Views / _FooterReport.cshtml');
},
error: function (data) {
}
});
This is an MVC project. 这是一个MVC项目。 The requests will be run through a route system. 这些请求将通过路由系统运行。 Take the URL for this page (for example: /home/page/
) and use it in the jQuery .load
statement. 取得此页面的URL(例如: /home/page/
),然后在jQuery .load
语句中使用它。
<div id="Footer">
<div id="partToBeReplacedWithLoadData">
@Html.Partial("_FooterReport")
</div>
</div>
And the jQuery load statement: 和jQuery load语句:
$('#Footer').load('/home/page/ #partToBeReplacedWithLoadData');
You won't be able to just request the file in the project. 您将无法仅在项目中请求文件。 It should go through a route first. 它应该先经过一条路线。 If you had a route and an action in a controller that returned only the footer partial that would work, too (something like: /home/footer/
). 如果您在控制器中有一条路线和一个动作,该动作和动作只返回了也会起作用的页脚部分(例如: /home/footer/
)。
This will not reload the whole page, but get just the contents of the #Footer
div. 这不会重新加载整个页面,而只会获取#Footer
div的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.