此代码块有什么区别:
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", "upload_url");
xhr.send(some_form_data);
还有这个:
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.upload.addEventListener("load", uploadComplete, false);
xhr.upload.addEventListener("error", uploadFailed, false);
xhr.upload.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", "upload_url");
xhr.send(some_form_data);
我在博客和其他 SO 帖子中都看到了这两种实现,但没有人解释为什么它们使用一种而不是另一种。在这一点上我能找到的唯一区别是后者不适用于默认的 Android 浏览器,而前者似乎几乎适用于所有东西。