AJAX JS and PHP error handling enhanced