确定AJAX调用成功的正确方法是什么?

nop*_*ole 1 javascript ajax httpresponse

确定AJAX调用成功的正确方法是什么?

我在prototype.js中看到了

    return !status || (status >= 200 && status < 300);
Run Code Online (Sandbox Code Playgroud)

在jQuery中:

    // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
    return !xhr.status && location.protocol == "file:" ||
        ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223;
Run Code Online (Sandbox Code Playgroud)

哪一个是正确的?如果我们不使用任何Javascript库但是在基本Javascript中编写AJAX,我们应该使用哪一个?

wor*_*ad3 5

原型似乎更"正确",因为它只将有效的HTTP成功代码视为成功.jQuery更加强大,因为它考虑了错误和其他经常成功的代码.