I have a portal having n tabs and whenever the visitor clicks a particular tab, an AJAX request is created. A PHP script at the back end inserts a record into a table which tracks the time of click and the name of the tab clicked.
When the visitor clicks the same tab multiple times, continuously, all the AJAX requests are succeeding. Say I click a tab "Automation" 5 times, then 5 AJAX requests are succeeding and 5 records are getting inserted. I need to limit the request to only one, if the visitor is repeatedly and quickly clicking the tab for an interval of 3s. How to go about this?
Here's my jQuery AJAX code :
$.ajax({
url : "pushTelemetry.php",
cache : false,
data : ({
DshBrdName : strFullDashBoardName,
DshBrdID : currentDashboard,
r : Math.random()
}),
success : function(data, textStatus, jQxhr){
//alert(textStatus);
},
error : function(jqXHR, textStatus, errorThrown){
//alert(textStatus);
alert(errorThrown);
},
type : "POST"
});