我正在使用jQuery的回调函数 。加载 如果运行某些代码的方法 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 ?
编辑/ UPDATE: 我现在相信 .load 是基于 .ajax,以下问题的答案可能对其他有类似问题的人有用: - 在jQuery的ajax成功回调中,textStatus会不会“成功”?