メソッドのパラメーターが特定の文字列と等しい場合、 jQuery の.loadメソッドのコールバック関数を利用して特定のコードを実行しています。textStatus
.load
たとえば、私は持っています
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
}
});
しかし、ステートメントのelse
一部がと等しくない他の予期しない値をキャッチする可能性があるのではないかと心配しています。if
textStatus
success
と以外に、textStatus に可能な他の値はerror
ありsuccess
ますか?
編集/更新:.load
私は今、それがに基づいていると信じているので.ajax
、次の質問の答えは、同様の質問を持つ他の人に役立つかもしれません:- jQueryのajax成功コールバックでは、textStatusは「成功」になりませんか?