When an ajax request is complete, data-poll repeats it until a callback returns true.
If you need to follow long-running tasks in the server's background, you might need to display progression information. This option let you set a callback (in the data-poll attribute), which is called on complete (whatever the ajax call succeeded or failed). Your callback receives the domajax-ed element as first parameter, and the ajax response as second parameter. It should return false if the polling should stop, or true if the ajax request should be run again. Coupled with data-delay, you can set an interval (in millisecs) between ajax calls.
This form looks like this:
<input type="button" value="Run" class="btn domajax click" data-endpoint="poll-progress-handler.php" data-poll="myPollingCallback" data-delay="1000" data-output="#percent" /> <div> Progression : <span id="percent">--</span> % </div> <script type="text/javascript"> function myPollingCallback(elem, response) { if (response === '--') { return false; } return true; } </script>
This form looks like this:
<p> </p> <label for="message">Enter a message</label> <input type="text" id="message" name="message" /> <br/> <input type="button" value="Send" class="btn domajax click" data-endpoint="poll-long-handler.php" data-input="#message" data-output="#output" /> <div class="domajax ready" data-endpoint="poll-long-handler.php" data-poll="" data-output="#output" ></div> <div id="output"></div>
All the documentation at a glance