我已經嘗試了幾個答案在這裏,但沒有工作。PHP AJAX回聲json數據然後睡覺
我有這個基本的蜜罐腳本:
if (!empty($_POST['starttime'])) {
$current_time = time();
$json = array();
$json = reGenerateFormFields();//hold the hashed keys arays for change in the key output.
if (($current_time - htmlentities(@$_POST['starttime'])) < 4) { // 3 is number of seconds differential
$return = array('hp' => true,'message' =>'אנא המתן 3 שניות בין שליחה','key' => $json['2'], 'nonce' => $json['1'],'time' => time());
echo json_encode($return);
sleep(7);
die();
}
}
我想呼應的JSON消息,然後睡覺,但那麼現在它的第一個做睡眠呼應的消息,任何想法如何做到這一點的好辦法嗎?
謝謝先進。
」首先做睡眠然後回覆信息_「不,它沒有。如果您在瀏覽器中查看輸出,則可能看起來如此。如果是這種情況,請在'sleep'之前的echo語句之後清空輸出。 – 2014-09-22 14:02:04
已經嘗試,沒有工作,它保持睡眠,然後消息。 – Ravg 2014-09-22 14:48:23
這應該做什麼'@ $ _ POST ['starttime']'? '@'抑制了函數/方法的錯誤,並且對變量沒有影響。 – DanFromGermany 2014-09-22 16:22:28