JS XMLHttpRequest.upload.addEventListener 傳參,回調

 

JS 回調函數,傳參的辦法。app

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);spa


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

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

相關文章
相關標籤/搜索