【发布时间】:2011-05-29 23:21:27
【问题描述】:
我有这些代码:
<script>
$.ajaxSetup({
timeout:3000,
success: function(){alert('True!!!');},
error:function (){
alert('false');
}
});
$.ajax({
url:'test.php',
});
</script>
我的“test.php”是:
<?
sleep(8);
$124415;
?>
所以它有解析器错误,但 ajax 立即返回“True”,但如果第二行有注释,它会等待 3 秒。并返回“假”。有什么想法吗? 我已经更改代码 test.php:
<?
function shutdown() {
header("HTTP/1.0 500 Internal Server Error");
ob_flush();
}
ob_start();
register_shutdown_function('shutdown');
spl_autoload_register('foo');// Fatal Error => Ajax false
//$112123123;//if turn on will be Parse Error => Ajax true
?>
所以现在 ajax 提醒我有关致命错误,但 Parser Error 没有捕捉到。有人知道这个问题的好方法吗?
【问题讨论】:
-
解析器错误仍然是 200 还是 500 状态到达客户端?
-
我怎样才能知道什么是错误?