Following function will help you to understand error code by throwing an error and displaying error definition in alert. error: function( xhr. You should be getting in jQuery ' error' callback. ajax / error: function( xhr, status, error) { alert( xhr. responseText) ; }. If you want a generic error you can setup all $. ajax( ) ( which $. get( ) uses underneath) requests jQuery makes to display. Just run this once before making any AJAX calls ( no changes to your current code, just stick this before. Try: error: function( xhr, status, error) { var err = eval( " ( " + xhr. responseText + " ) " ) ; alert( err. Here' s an example of how you get JSON data on error: $. ajax( { url: ' / path/ to/ script. php', data: { ' my' : ' data' }, type: ' POST' } ).
fail( function( $ xhr) { var data = $ xhr. responseJSON; console. log( data) ; } ) ;. From the docs: If json is. ajax( { / / just showing error property error: function( jqXHR, error, errorThrown). Custom exception ModelStateException that gets thrown when validation fails on the server ( model state reports validation errors when. ajax( { type: " POST", url: " some. php", data: " name= John& location= Boston", success: function( msg) { alert( " Data Saved: " + msg ) ; }, error:. Prior to jQuery 1. 8, the function done was called success and fail was called error. jQueryでajaxリクエストを投げ、 エラーが返ってきたときに、 レスポンスの中身をパース する方法を紹介します。. attr( ' data- name' ) + '.
ajax( { type: ' GET', dataType: ' json', url: url, error: function( xhr, textStatus,. ajax( { url: php", data: { }, complete: function( xhr, statusText) { alert( xhr. status) ; }, error: function( xhr,. I found this solution where you can simply, check the server response code using status code.