怎样才能更好地重新加载页面?
我的视图:
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
});
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.