添加Ajax呼叫冷却

I've searched both Google and StackOverflow but with no luck.

I have a system where when a page loads, it calls an advert via ajax. It works good but I want it such that it wouldn't make a call if it has been less that 60 seconds since the last call. In other words, a cool down time between ajax calls.

My ajax call:

$.ajax({
    type: 'GET',
    url: '../ad',
    cache: false,
    success: function(data) {
    $("#cat").html(data);
  }
});

I've tried using an IF statement with a variable countdown but it didn't work.

Thanks in advance.

    setInterval(function(){$.ajax({
    type: 'GET',
    url: '../ad',
    cache: false,
    success: function(data) {
    $("#cat").html(data);
    }
    })},60000); //60 sec

Use setInterval to run the ajax function on every second, always keeping track of the times the handler has been called and then call the ajax function only if the count equals or is greater than 60...

var count = 60;//make sure you initialize it to 60 to guarantee the first call immediately

setInterval(function(){
    count++;//increase the count

    if(count >= 60){
        $.ajax({
            type: 'GET',
            url: '../ad',
            cache: false,
            success: function(data) {
            $("#cat").html(data);
            count = 0;//reset the count
          }
        });}
}, 1000);//runs on every second