HTML5上传文件如果用jQuery ajax发送怎么监听事件?

Kellen_He Kellen_He 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
var xhr = new XMLHttpRequest();
var fd = document.getElementById('form1').getFormData();

/* event listners */
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
/* Be sure to change the url below to the url of your upload server side script */
xhr.open("POST", "upload.php");
xhr.send(fd);

网上的H5上传文件例子都是用XMLHttpRequest发送, 我这里需要用$.ajax()来发送,
那么问题来了,请问uploadProgress,uploadComplete等事件如何监听?
...全文
评论 4
收藏 已收藏
分享
返回顶部
Kellen_He
JavaScript 87,984 成员 224,680 内容