Use Laravel Log to debug it in Laravel:
Log::info('Whatever you need to send to your log');
And check your log for your messages and all error messages:
php artisan tail
سؤال
I want to know how to debug ajax in Laravel 4, because when error, I only get and error 500.
I'm making ajax request with jQuery.
المحلول 2
Use Laravel Log to debug it in Laravel:
Log::info('Whatever you need to send to your log');
And check your log for your messages and all error messages:
php artisan tail
نصائح أخرى
Another easier answer is:
In Chrome,
The full error message is visible there.
Another way, and, to have more specificity of the error (like 500 Internal Server Error), surround your code into a try/catch block and send the error/exception message as a JSON object for instance.
$.post('http://localhost/post_request,
{
'_token': $('meta[name=csrf-token]').attr('content'),
'input_xxx': 'value'
})
.fail(function(data) {
data.error / data.debug
})
.success(function(data) {
});
--------------***---------------
try{
//post request action(s) handling here
}catch(Exception $e){
return response()->json([
'error' => 'Whoops, looks like something went wrong.',
'debug'=> $e->getMessage()
]);
}