首页 > 代码库 > JS XMLHttpRequest.upload.addEventListener 传参,回调

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();
}

JS XMLHttpRequest.upload.addEventListener 传参,回调