I use $ajax
我的 PHP 网站的许多部分的请求一切都运行良好,直到几天前我的所有$ajax
请求开始给予error 500 - internal server error
。
我可以在控制台中看到该错误,并且我还使用错误处理程序来获取有关该错误的更多信息。
这是我的 Ajax 请求
window.setInterval(function(){
$.ajax({
type: "GET",
url: "include-ajax/is_it_midnight.php",
dataType: "json",
success: function(data)
{
if(data == 1)
{
//Reload website at midnight
location.reload();
}
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest);
alert(textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
}
});
}, 10000);
这就是我在浏览器上得到的:
is_it_midnight.php:
<?php
$current_hour = date('H');
$current_minute = date('i');
$current_second = date('s');
//If the website was open between the 00:00:00 and 00:00:10 it will refresh automatically
//else it will not be open it will open after midnight so it will have aleardy the new day data
if($current_hour == 0 && $current_minute == 0 && ($current_second > 0 && $current_second < 10))
{
$is_it_midnight = 1;//This flag means it is midnight
}
else
{
$is_it_midnight = 2;//This flag means it is not midnight
}
echo json_encode($is_it_midnight);
?>
一些注意事项:
1.它并不总是出现此错误,有时它工作正常并正确地提供响应(我在网站上以及当我在 Chrome 控制台中检查网络选项卡时看到响应和标头信息)。
2.类型是GET还是POST并不重要,它总是给我同样的问题(我用GET类型展示了这个ajax示例,但我的网站中也有POST类型请求,也有同样的问题)。
3.我添加ini_set('display_errors',1);``ini_set('display_startup_errors',1);``error_reporting(-1);
到开始is_it_midnight.php
但没有显示错误,因为我相信没有语法或任何其他 php 错误(因为有时它工作正常且正确)。
4. 我还检查了服务器错误日志,但根本没有与此文件或任何其他 ajax 文件相关的内容。
5. 我尝试检查这是否是超时错误,但没有得到任何结果timeout
from textStatus
它只是提醒error
.
UPDATE :
我检查了 apache 日志,发现了这样的内容:[Sat Feb 21 07:35:05 2015] [error] [client 176.40.150.195] Premature end of script headers: is_it_midnight.php, referer: http://www.example.com/index.php
我需要任何有用的帮助或线索来了解为什么我会收到此错误,是否有什么我没有尝试获取有关该错误的更多信息???