Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are all of the possible values of the textStatus parameter in the callback function of jQuery .load?

Tags:

jquery

I am utilising the callback function of jQuery's .load method to run certain code if the textStatus parameter of the .load method is equal to a certain string.

e.g. I have

jQuery("#myContainer").load('/seperate-file-with-content.asp', function(responseText, textStatus, xhr){                     
    if (textStatus === "error" || responseText.length <= 0) {
        //file failed to load i.e. textStatus == error 
        //or file loaded but has no content
    } else {
        //file loaded successfully i.e. textStatus == success
    }       
});

But i'm worried that the else part of the if statement may catch other non expected textStatus values that aren't equal to success.

Are there any other possible values to textStatus, other than error and success ?

EDIT/UPDATE: As I now believe that .load is based on .ajax, the answers in the following question may be of use for anyone else with a similar question:- In jQuery's ajax success callback, will textStatus ever not be "success"?

like image 493
Dave Haigh Avatar asked Jun 19 '12 15:06

Dave Haigh


1 Answers

load() is based on $.ajax(), and the documentation for this method lists the possible statuses as:

  • abort
  • error
  • notmodified
  • parsererror
  • success
  • timeout
like image 127
Frédéric Hamidi Avatar answered Oct 07 '22 18:10

Frédéric Hamidi