好的,所以我尝试使用 .htaccess 为各种错误代码设置 ErrorDocuments。它工作得很好,除了现在,以下 jQuery AJAX 代码将永远不会运行 error() 函数:
$.ajax({url: url, type: "GET", cache: false, error: function(){
alert("Looking rather erroneous, are we?");
}, success: function(html){
// ...
}
有什么建议吗?我想我知道原因: .htaccess 指出所有错误,如下所示:
ErrorDocument 404 /error.php
并且 /error.php 具有以下内容:
<?php header("Location: /#error"); ?>
所以当它传输到 index.php 时,它可能会丢失 404 文档状态。
你有什么建议?