jQuery .load的回调函数中textStatus参数的所有可能值是什么?
我正在利用jQuery的.load方法的回调函数来运行某些代码,如果textStatus
方法的textStatus
参数等于某个字符串。
我有
jQuery("#myContainer").load('/seperate-file-with-content.asp', function(responseText, textStatus, xhr){ if (textStatus === "error" || responseText.length <= 0) { //file failed to load ie textStatus == error //or file loaded but has no content } else { //file loaded successfully ie textStatus == success } });
但我担心if
语句的else
部分可能会捕获其他非预期的textStatus
值,这些值不等于success
。
除了error
和success
之外,textStatus还有其他可能的值吗?
编辑/更新:我现在认为.load
基于.ajax
,以下问题中的答案可能对其他有类似问题的人有用: – 在jQuery的ajax成功回调中,textStatus将不会“成功” ?
load()
基于$ .ajax() ,此方法的文档列出了可能的状态:
-
abort
-
error
-
notmodified
-
parsererror
-
success
-
timeout