data-counter

Contains number of times the ajax call has been made.

Each time an ajax request is made, data-counter is incremented. Combined with data-limit, you can control the maximum number of times your ajax call can be made. At any time, you can use $('selector').data('counter') to get the counter's current value.

By default, data-counter is set to 0.

Usage


  • data-counter="(initial number)"

Example


  • data-counter="0"

Live examples

This form looks like this:


<input
        id="test"
        type="button"
        value="Do an ajax call"
        class="btn domajax click"
        data-endpoint="counter-value-handler.php"
        data-output="#output"
        />

<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>


See also    data-limit 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax