XMLHttpRequestEventTarget.onprogress
is the function called periodically with information when an
XMLHttpRequest
before success completely.
XMLHttpRequest.onprogress = callback;
callback
is the function to be called periodically before the request is completed.
event.loaded
the amount of data currently transfered.
event.total
the total amount of data to be transferred.
XMLHttpRequest.onprogress = function (event) {
event.loaded;
event.total;
};
var xmlhttp = new XMLHttpRequest(),
method = 'GET',
url = 'https://developer.mozilla.org/';
xmlhttp.open(method, url, true);
xmlhttp.onprogress = function () {
//do something
};
xmlhttp.send();
| 规范 | 状态 | 注释 |
|---|---|---|
| XMLHttpRequest | 实时标准 | WHATWG (Web 超文本应用程序技术工作组) 实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onprogress
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
XMLHttpRequestEventTarget
onabort
onerror
onload
onloadstart
onprogress