Perhaps to create a JSON object containing fatal error information, use register_shutdown_function . Then use the AJAX call to verify the file; parse the return value from the call to see if there is an error. (Obviously, you can also run the PHP file and parse the JSON object without using AJAX, just by thinking about what would be better from a UX perspective)
function my_shutdown() { $error = error_get_last(); if( $error['type'] == 1 ) { echo json_encode($error); } } register_shutdown_function('my_shutdown');
Will output something like
{"type":1,"message":"Fatal error message","line":1}
Prepare this for the start of the test file, then:
$.post('/test.php', function(data) { var json = $.parseJSON(data); if( json.type == 1 ) {
andrewtweber
source share