I have an ajax GET request with a 2 second timeout. I do not want the request to still hang there if the request expires. After 2 seconds, I just want to stop everything.
I am wondering if abort() needs to be called if the timeout is reached, or reaches the timeout threshold, automatically abort everything ...?
request = $.ajax({ type: 'GET', url: url, timeout: 2000, success: function (data) { // do some stuff }, error: function(x, t, m) { if(t==="timeout") { request.abort(); // is this necessary? // do some other stuff } // end if timeout } // end error function }); // end ajax
source share