JS XMLHttpRequest.upload.addEventListener 传参,回调

 

JS 回调函数,传参的办法。

function uploadFile(t) {
var fd = new FormData();
fd.append("_netLogo", document.getElementById(‘_netLogo‘).files[0]);
var xhr = new XMLHttpRequest();

// 原来 xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.upload.addEventListener("progress", function () { uploadProgress(event,t) }, false);


xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", "/User/WNetEdit2_test");
xhr.send(fd);
}

function uploadProgress(evt, t) {
$(t).parent().find("._ProgressNum").remove();
}

文章来自:http://www.cnblogs.com/90nice/p/4080333.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3