[jQuery] ajax - no callback on timeout
Hi,
Does anybody know how to trigger timeout function.
If database does not respond in 5 seconds
I need to display some notification to user.
The following example did not trigger any callback after 5 seconds.
jQuery.ajax({
type: "POST",
url: 'proccess.php',
timeout:5000,
dataType: "json",
cache: false,
success: function (XHR, status, e) {
alert('success: ' + XHR + ' status: ' + status + ' e: ' +
e);
}
,error: function (XHR, status, e) {
alert('error: ' + XHR + ' status: ' + status + ' e: ' + e);
}
,complete: function (XHR, status, e) {
alert('complete: ' + XHR + ' status: ' + status + ' e: ' +
e);
}
});
// proccess.php
<?php
sleep(30);
exit;
?>