簡體   English   中英

如何在php和js結合使用警報

[英]how to use alert in php and js combined

需要通過php發出警報,
我有下面的代碼。 問題是,只要我不使用標頭重定向,它就可以工作。 但是,一旦我使用它。

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

重定向指示瀏覽器立即觸發全新請求。 帶有警報的響應正文將被忽略。 您可能要使用JS來在警報后激發新請求。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM