Replace current page with ajax content

前端 未结 9 1279
南旧
南旧 2020-12-05 04:50

I have a page with a dialog window which sends ajax post data to server and receives a response. During development, there can be two responses - one regular (this is not th

9条回答
  •  一个人的身影
    2020-12-05 05:23

    In your ajax callback:

    success: function (data) {
       $("html").html($(data).find("html").html());
    }
    

    That will replace the entire page's HTML content with the one received from your AJAX request. Works in Chrome... not sure about IE.

    Despite that, I'm not sure why you'd want to include the section... but you can easily modify the above to display just what's in the body of the AJAX response, and append it to a div or even a lightbox. Much nicer.

提交回复
热议问题