Search code examples
jqueryajaxform-post

ajax Post gets stuck in a "Post" state


I am having an issue when doing a Post with ajax. I have both a "success" and an "error" function.Unfortunately my post never reaches either function and it stays in a "Post" state. I believe it's a network issue and if so what can I do to catch that and attempt to post again. I don't want to create multiple records by posting multiple times though.


Solution

  • Create an "always" callback function like this example:

    $.ajax( "example.php" )
      .done(function() {
        alert( "success" );
      })
      .fail(function() {
        alert( "error" );
      })
      .always(function() {
        alert( "complete" );
      });