weixin_33726318 2019-02-26 12:32 采纳率: 0%
浏览 116

怎样才能更好地重新加载页面?

怎样才能更好地重新加载页面?

我的视图:

def logout(request):
  auth.logout(request)
  html = render(request, 'base.html')
  return html

Ajax

$('a[href$="logout/"]').click(function () {
    $.ajax({
        url: '{% url "logout" %}',
        type: 'GET',
        success: function (data) {
            $('body').html(data);
        }
    });
    return false
});
  • 写回答

1条回答 默认 最新

  • weixin_33693070 2019-02-26 12:38
    关注

    Are you loading all of you pages like this? If it is traditional multi page web application, why not just send regular Http request instead of XMLHttp request?

    If you load all pages like this $('body').html(data); then you will have some performance issues after some time. If you don't want to reload your pages, create a Single Page Application (SPA) with React, Angular or Vue.

    评论

报告相同问题?