I am using jQuery getJSON() function. This function getting data with no problem. But sometimes waiting, waiting waiting... And my loading bar showing loading loadi
getJSON()
getJSON() returns a promise on which you can call the abort function :
abort
var p = $.getJSON(..., function(){ alert('success');}); setTimeout(function(){ p.abort(); }, 2000);
EDIT : but if your goal is just to abort if it takes too much time, then lethal-guitar's answer is better.