jQuery Form Plugin — does not call error callback on Internal Server error (500)

I have a server returning Status code 500 and my jQuery Form calls the success callback instead of the error callback.

jQuery version: 1.7.1
jQuery Form version: 2.73 march 2011
server apache2

  • Simple key/value database
  • how to send a file and an input field using JavaScript and Ajax to send a php script
  • Send form data using ajax
  • JQuery on dropdown list change is not working in codeigniter
  • ASP.NET AJAX UpdatePanel - cancelling postback in InitializeRequest will not set back to re-enabled
  • Getting XML nodevalue with Javascript
  • These are some code snippets:

    var options =
           error         : on_upload_error
        ,  success       : on_upload_succes
    // bind form using 'ajaxForm'
    $( '#upload-form' ).ajaxForm( options );
    function on_upload_error( jqXHR, textStatus, errorThrown )
        console.log( "in error function" );
    function on_upload_succes( responseText, statusText, xhr, form )
        console.log( 'responsText: ' + responseText );
        console.log( 'statusText: ' + statusText );
        console.log( xhr );
        console.log( form );
        // ....

    The headers from the server seem correct to me:

    HTTP/1.1 500 Internal Server Error
    Date: Wed, 09 May 2012 18:35:11 GMT
    Server: Apache/2.2.16 (Debian)
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 405
    Connection: close
    Content-Type: text/html; charset=iso-8859-1

    I can’t get this to show “in error function”. On top of that, the statusText parameter returned to on_upload_success contains a string “success”.

    All clues welcome

  • How to set up AJAX call tracking in Google Analytics?
  • How to continue form submission after an AJAX call?
  • Get List of Albums Google Picasa
  • Check for false
  • Sending ajax request and receiving response (synchronised)
  • How to call JS function through ajax call
  • 2 Solutions collect form web for “jQuery Form Plugin — does not call error callback on Internal Server error (500)”

    You should use alert(xhr.responseText); to see the error message associated.

    First of all , The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the web site’s server but the server could not be more specific on what the exact problem is.

    It is know for jquery not to call error function upon occurance of 500 internal error , so the usual way of handling this is using status code

        statusCode: {
            500: function() {
              alert("Something went wrong !");

    for more info about using status code , review jquery api:

    more info about failure to handle 500 error:
    Handle 500 errors in JSON (jQuery)

    also check this out :
    jquery ajax ignores 500 status error