debugging jquery ajax script with runtime error
If I am right then you are asking to handle error while calling the ajax to the ajax complete. The jquery ajax has a parameter callback function for error, you can use that callback to handle your error.
$.ajax({...error: function(error){console.log(error);}...})
If you want to handle total error you can use try catch block wrapping around the total ajax call.Hope this will help you})