0

have a need to alert through php,
I have the code below. Problem is that it works as long as I dont use header redirect. But as soon as I use it..I loose alert.

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

1 Answer 1

2

A redirect instructs the browser to immediately fire a brand new request. The response body with the alert will be ignored. You may want to use JS instead to fire a new request after the alert.

if ($value == 1) {  
    alert('ok working');  
    window.location = 'someOtherpagethanthis.php';
}  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.