XMLHttpRequestEventTarget.onload
XMLHttpRequestEventTarget.onload
是 XMLHttpRequest
请求成功完成时调用的函数。
语法
XMLHttpRequest.onload = callback;
值
callback
是请求成功完成时要执行的函数。它接收一个ProgressEvent
对象作为它的第一个参数。this 的值(即上下文)与此回调的XMLHttpRequest
相同。
示例
var xmlhttp = new XMLHttpRequest(),
method = 'GET',
url = 'https://developer.mozilla.org/';
xmlhttp.open(method, url, true);
xmlhttp.onload = function () {
// 处理取回的数据(在 xmlhttp.response 中找到)
};
xmlhttp.send();
规范
Specification | Status | Comment |
---|---|---|
XMLHttpRequest | Living Standard | WHATWG living standard |
浏览器兼容性
BCD tables only load in the browser