/ Published in: jQuery

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var pendingCall = { timeStamp: null, procID: null }; $('li a').click(function (e) { e.preventDefault(); var getUrl = $(this).attr("href"); var timeStamp = Date.now(); var printCall = function () { $.ajax({ url: getUrl, type: "GET", beforeSend: function () { }, error: function (request) { alert(request) }, success: function (data) { if (pendingCall.timeStamp != timeStamp) { return false; } $('#graphContent').html(data); pendingCall.procID = null; } }); }; if (pendingCall.procID) { clearTimeout(pendingCall.procID) }; pendingCall = { timeStamp: timeStamp, procID: setTimeout(printCall, 3000) }; });
Comments
