responseText为空,但在控制台上显示?

joh*_*hod 7 javascript ajax jquery xmlhttprequest

这可能是一个愚蠢的错误,但我正在使用JQuery ajax来对付PHP后端,我希望PHP脚本将进度发布回网页.

它看起来工作正常,但我无法获得e.target.responseText的内容.

如果我执行console.log(e.target),我会在控制台中获取XMLHttpRequest对象.我可以看到responseText:"1 av 1500 linjer"

但是,如果我执行console.log(e.target.responseText),它就是空的.

我迷失了吗?

这是我的功能:

$.ajax(
    {
        type: "POST",
        url: "modEcs/ajax/ecs.php?a=analyseExcel",
        processData: false,
        contentType: false,
        xhrFields: 
        {
        onprogress: function(e) 
        {               
            console.log(e.target);
            console.log(e.target.responseText);  
            }
        },
        success: function(data) 
        {

         },
         error: function (xhr, ajaxOptions, thrownError) { alert(xhr.statusText); }
    });
Run Code Online (Sandbox Code Playgroud)

控制台中的数据:

XMLHttpRequest
onabort: null
onerror: null
onload: null
onloadend: null
onloadstart: null
onprogress: function(e)
onreadystatechange: null
ontimeout: null
readyState: 4
response: "1 av 1500 linjer"
responseText: "1 av 1500 linjer"
responseType: ""
responseURL: "xxx"
responseXML: null
status: 200
statusText: "OK"
timeout: 0
upload: XMLHttpRequestUpload {onloadstart: null, onprogress: null, onabort: null, onerror: null, onload: null, …}
withCredentials: false
XMLHttpRequest-prototype
Run Code Online (Sandbox Code Playgroud)

小智 1

进度仅在 XMLHTTPRequest 期间触发,而不是在收到响应结束时触发

readyState 3: "Downloading; responseText holds partial data."
Run Code Online (Sandbox Code Playgroud)