0
我有一個jQuery ajax調用去服務器backend.php腳本並告訴睡眠13秒(或更多),然後再用一個簡單的測試信息。我看到的是在10秒後觸發ajax成功函數(在螢火蟲中觀察到200響應),但沒有來自服務器的實際響應。如果我將響應延遲設置爲小於10秒,我會完美地收到響應消息。Ajax jQuery在10秒後成功返回,當它不應該
這是你以前見過的東西嗎?有一些默認的PHP超時事情嗎?
ajaxcall = $.ajax({
type: "GET",
url: "backend.php",
async: true,
cache: false,
dataType: 'json',
timeout: 30000,
/* Timeout in ms. Default to 30000 (30 seconds) */
data: "TimeStamp=" + TimeStamp,
success: function(data) {
if (data !== null) {
$('#TextHistory').append(data.message);
if (data.timestamp != 0)
{
TimeStamp = data.timestamp;
}
}
setTimeout(
waitForMsg, /* Request next message */
5000 /* ..after 5 seconds, default to 5000*/);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#TextHistory').append('<p>Error:' + errorThrown + '</p>');
setTimeout('waitForMsg()',"15000"); /* milliseconds (15seconds) default to 15000 */
}
});
}在服務器端
..和我只是這樣做:
<?php
header('Content-Type: application/json');
sleep(13); // Changing this to test it. Will only work if less than 10
$When = date("H:i:s",strtotime("now"));
$response["message"] = "<p>Small Test $When</p>";
$response["timestamp"] = 123456789;
echo json_encode($response);
?>
Hi..thanks,明顯的max_execution_time設置爲30(假定秒)...... – 2011-03-04 18:21:13
@ Dan Twining,通常關於時間的數字是指**毫秒** – Shoe 2011-03-04 18:24:10
好吧,好吧......我嘗試設置「set_time_limit(35);」在我的後端腳本中,並得到消息「警告:set_time_limit()由於安全原因已被禁用......」我有一個與streamline.net共享的託管帳戶,所以我猜測沒有任何東西我能做些什麼呢? – 2011-03-04 18:30:07