I have the following script validation.php
<?php
if(!isset($_SESSION['userId'])){
session_destroy();
header('Location: home.php');
exit;
}
?>
I would like to execute this script every time someone clicks a button in the #main-display
$("#main-display").on('click', 'button', function (event){
//some code in here
});
How would I go about doing this?
You cant do a redirect from within a ajax request directly since it will only redirect the response page to home.php and not the current main DOM window.
You are going to have to modify it to something like this in the php:
And then on the javascript