I make a GET request with ajax and expect a JSON value to be returned.
However, my hosting has a firewall installed. It only takes 2 requests per second, otherwise blocks the connection and shows an error page. (a blank page.) So if I make 3 requests in a second, third request never retrieve the JSON response. Hence, loading.gif keeps turning and turning.
How can I make a timeout in jQuery, let's say 5 seconds, so it'll callback the timeout function?
$.ajaxaccepts atimeoutoption. You can then test in the error handler what the cause for the error was (e.g. the timeout). Please have a look at the documentation: api.jquery.com/jQuery.ajax.