timeout property
Gets or sets the time-out value.
![]() |
Syntax
| JavaScript | |
|---|
Property values
Type: Integer
the number of milliseconds that the browser is to wait for a server response. Default value is 0.
Remarks
If the time-out period expires, the responseText property will be null.
You should set a time-out value that is slightly longer than the expected response time of the request.
The timeout property may be set only in the time interval between a call to the open method and the first call to the send method.
If you set an XMLHttpRequest time-out value that is larger than the network stack's time-out value, the network stack will time out first and the ontimeout event will not be raised.
Examples
The following example sets the timeout property.
var xhr; xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.timeout = 10000; xhr.ontimeout = timeoutFired; xhr.send(null);
See also
