$.ajax(
url:"",
async: true,
timeout: 2*60*60*1000, //2 hours,
success: function(){},
error: function(){}
);
In a jQuery ajax request, if I set the timeout with a big value, or left it empty, will it keep waiting until the server returns a result?
Actually, I expect the server will response in 1.5 hours, so in my js script I set timeout to 2 hours, but I found the Ajax jump to error function (with msg code 404) in less than 1 hour. It means ajax abort the waiting ahead of the time .
So I wonder if there is a maximum timeout value can ajax be set?
Default global value of
timeout
is 0 that means it is infinite.My previous answer was wrong (timeout just seemed to be to short and I couldn't believe it myself) so I have done a test yesterday, created 1GB zip then throttled my connection with fiddler and wrote this aspx page.
then I ran this script (interestingly fiddler blew up with OutOfMemory exception within 10 seconds however response was held).
It came back with
9393076/1000 ~ 9393(s) = 02:36:33
Which equals to ~156 minutes.
I will repeat this test this weekend to see if it will timeout after same amount of time, but so far it seems it is more than 7200000 (2*60*60*1000).