gpt4 book ai didi

jquery - pjax - 出现错误时渲染页面

转载 作者:行者123 更新时间:2023-12-01 02:20:10 24 4
gpt4 key购买 nike

我正在使用 pjax,我想将其配置为呈现页面(替换 html),就好像一切正​​常一样,即使页面响应非 200 代码(404、500)。

我的 404 和 500 页面已调整为看起来不错,并且我不需要 pjax 来刷新页面。

我无法从我读过的所有文档中弄清楚如何做到这一点,包括 original git repo 。欢迎任何帮助。

最佳答案

您可以从 pjax:error 处理程序调用 success 函数,并返回 false 以防止自动硬刷新:

$(document).on('pjax:error', function(event, xhr, textStatus, errorThrown, options) {
options.success(xhr.responseText, textStatus, xhr);
return false;
});

关于jquery - pjax - 出现错误时渲染页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24113407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com