简体   繁体   中英

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:

$('#Footer').load('/Views/_FooterReport.cshtml'); and i get this error:

GET http://localhost:2885/Views/_FooterReport.cshtml 500 (Internal Server Error)

 <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');

                    },
                    error: function (data) {
                    }

                });

This is an MVC project. 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.

<div id="Footer">
    <div id="partToBeReplacedWithLoadData">
        @Html.Partial("_FooterReport")
    </div>
</div>

And the jQuery load statement:

$('#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/ ).

This will not reload the whole page, but get just the contents of the #Footer div.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM