--- title: timeout slug: Web/API/XMLHttpRequest/timeout_event tags: - XHR - XMLHttpRequest - events - timeout translation_of: Web/API/XMLHttpRequest/timeout_event ---
当进度由于预定时间到期而终止时,会触发timeout
事件。
冒泡 | 否 |
可取消 | 否 |
目标对象 | {{domxref("XMLHttpRequest")}} |
接口 | {{domxref("ProgressEvent")}} |
var client = new XMLHttpRequest()
client.open("GET", "http://www.example.org/example.txt")
client.ontimeout = function(e) {
console.error("Timeout!!")
}
client.send()
timeout
事件实现了 {{domxref("ProgressEvent")}} 接口,它继承自 {{domxref("Event")}} — 它拥有在这个接口上定义的属性和方法。
Specification | Status | Comment |
---|---|---|
{{SpecName('XMLHttpRequest')}} | {{Spec2('XMLHttpRequest')}} |