2010-06-16 19 views
0

有必要通過PHP提醒,
我有下面的代碼。問題是,只要我不使用頭重定向,它就會工作。但是一旦我使用它,我就會失去警覺。如何在PHP中使用警報和js合併

echo "I will do some functions here in php"; 
if($value == 1){ 
alert('ok working'); 
} 
header(location: 'someOtherpagethanthis.php'); 

回答

2

一個重定向指示瀏覽器立即火了全新的要求。具有警報的響應主體將被忽略。您可能希望使用JS來在警報後觸發新的請求。

if ($value == 1) { 
    alert('ok working'); 
    window.location = 'someOtherpagethanthis.php'; 
}