How to limit a call to function?
<p>I'm currently looking for the best solution to limit the number of requests to a function.</p>

<p>Example:</p>

<pre><code>function CheckData() {
    if (d == "newdata") {
        GetData(2);
    }
}

function GetData(getcheck) {
    // Ajax Request here
}
</code></pre>

<p>The solution I am looking for is a way so that when CheckData calls GetData is there a way to limit how often it can call GetData, or better still if there is a bulk of requests that has suddenly come through, is there a way to make it say only get the last request?
So basically can it check the frequency of requests so that you can say its stopped a bulk of requests send the last one now?</p>

<p>I am just looking for a way to limit how often CheckData can call GetData but the best possible way to minimize wait.</p>

<p>I have looked at a few solutions and I am not sure how to apply it to this situation.</p>
