$.ajax({
type: 'POST',
url: '/test.php',
data: {
'test': 'phptest'
}//,
//dataType : 'json'
}).done(function (xhr, status, error) {
console.log(xhr);
console.log(status);
console.log(error);
$('#test').html(xhr);
}).fail(function (textStatus, errorThrown) {
$('#test').html(textStatus+': '+errorThrown)
});
test.php:
<?php
echod $_POST['test'];
?>
Notice I purposely use 'echod' so it throws an error. How can I catch this type of error on return in my done function?
.fail would catch a connection problem to test.php which there isn't.
So, as is, this completes successfully yet my return (xhr) is Parse error: syntax error, unexpected '$_POST' (T_VARIABLE)....
which is the error returned from test.php. That is what I want to catch.