I am using AJAX to run a php file and send data with it. Currently I use
complete: function() {
location.reload();
}
To reload the page after the php file is done. What I want is that when there is an error in the external php file, an alert is displayed (Bootstrap). Displaying an alert is not the problem, I have a function for that that accepts the string and type of alert but that is in PHP. That leads me to two questions;
How do I get data back from the AJAX call?
How do I use that data to display an alert with a PHP function (after a reload possibly)?
Thanks!
EDIT: In my external php file I have:
header('Content-Type: application/json');
$error = 1;
echo json_encode($error);