Timeout will be thrown as part of error, you can check if the error reason was timeout and call your function there!
The three arguments for the error handler are xmlhttprequest, textstatus, and message.
When a timeout happens, the status arg will be 'timeout'.
$.ajax({
type: "GET",
url: "xajax.php",
timeout: 100,
data: "name=John&location=Boston",
success: function(msg){ alert( "Data Saved: " + msg ); }
error: function(xmlhttprequest, textstatus, message) {
if(textstatus==="timeout") {
alert("Timeout happened"); //run function here!
} else {
alert(textstatus);
}
}
});
Possible values for textstatus
are (ignoring null) "timeout", "error", "notmodified" and "parsererror".
Related doc is at http://api.jquery.com/jQuery.ajax/