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.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言爬虫的时候元素和园代码不一样怎么解决呀
  • ¥15 VS2022多项目启动有问题
  • ¥15 SQL删除添加数据后序号不连续问题。
  • ¥15 首次运行OmniEvent运行报错
  • ¥15 有没有人知道这个问题怎么解决
  • ¥15 comsol电力电缆载流量仿真
  • ¥15 webSocket可以接TCP socket接口吗
  • ¥60 mpi并行出错,CFD++计算
  • ¥15 c#:vsto,powerpoint的外接程序中换主题颜色
  • ¥15 状态机/汽车转向灯/Sateflow