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,我们应该使用哪一个?