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 Stata链式中介效应代码修改
  • ¥15 latex投稿显示click download
  • ¥15 请问读取环境变量文件失败是什么原因?
  • ¥15 在若依框架下实现人脸识别
  • ¥15 添加组件无法加载页面,某块加载卡住
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用