Limit your ajax call to a given number of times.
domajax will work as soon as data-counter < data-limit. This means, if data-limit is set to
a number greater than -1, your ajax call will be limited to this number of calls. When this limit is reached, your domajax declaration
will not work anymore, until you reset data-counter, $('selector').data('counter', '0');
.
This form looks like this:
<p>In this example, you can do only 3 ajax calls</p> <input id="test" type="button" value="Do an ajax call" class="btn domajax click" data-endpoint="limit-three-handler.php" data-output="#output" data-limit="3" /> <br/><br/> <input type="button" id="get" class="btn" value="Get counter value" /> <br/><br/> <input type="button" id="reset" class="btn" value="Reset counter value" /> <br/><br/> <div id="output"></div> <script type="text/javascript"> $('#get').click(function() { alert($('#test').data('counter')); }); $('#reset').click(function() { $('#test').data('counter', 0); }); </script>
All the documentation at a glance