I am trying to handle errors in Ajax. For this, I am simply trying to reproduce this SO question in Symfony.
$.ajaxSetup({
error: function(xhr){
alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
}
});
but I can't figure out what the code in the controller would look like in Symfony2 to trigger header('HTTP/1.0 419 Custom Error');
. Is it possible to attach a personal message with this, for example You are not allowed to delete this post
. Do I need to send a JSON response too?
If anyone is familiar with this, I would really appreciate your help.
Many thanks