--- title: XMLHttpRequestEventTarget.onloadstart slug: Web/API/XMLHttpRequestEventTarget/onloadstart translation_of: Web/API/XMLHttpRequestEventTarget/onloadstart ---
{{APIRef("XMLHttpRequest")}}

XMLHttpRequestEventTarget.onloadstart 在{{domxref("XMLHttpRequest")}} 开始传送数据时被调用

语法

XMLHttpRequest.onloadstart = callback;

示例

var xmlhttp = new XMLHttpRequest(),
  method = 'GET',
  url = 'https://developer.mozilla.org/';

xmlhttp.open(method, url, true);
xmlhttp.onloadstart = function () {
  console.log("Download underway");
};
xmlhttp.send();

规范

规范 状态 说明
{{SpecName('XMLHttpRequest', '#handler-xhr-onloadstart')}} {{Spec2('XMLHttpRequest')}} WHATWG 现存标准

浏览器兼容性

{{Compat("api.XMLHttpRequestEventTarget.onloadstart")}}