UNPKG

intercooler

Version:

Making AJAX as easy as anchor tags

54 lines (39 loc) 1.56 kB
--- layout: default nav: attributes > ic-poll --- <div class="container"> <div class="row"> <div class="col-md-12"> <h2><code>ic-poll</code> - The Poll Attribute</h2> <h3>Summary</h3> <p>The <code>ic-poll</code> attribute tells Intercooler to poll the URL given by a <a href="/attributes/ic-src.html"><code>ic-src</code></a> attribute on a given interval.</p> <h3>Syntax</h3> <p>The value of the attribute should a valid integer, followed by the string "s" (for seconds) or "ms" (for milliseconds). (e.g. ic-poll="100ms" indicates that the server should be polled every 100 milliseconds.) </p> <h3>Dependencies</h3> <p><code>ic-poll</code> has no dependency implications.</p> <h3>Example</h3> <p>Here is a simple example of a poll interval:</p> <pre> &lt;div ic-src="/seconds" ic-poll="2s">You have been on this page for 0 seconds...&lt;/div> </pre> <div class="live-demo"> <script> (function () { var init = Math.floor(new Date().getTime() / 1000); $.mockjax({ 'url': '/seconds', 'response': function () { var seconds = Math.floor((new Date().getTime() / 1000) - init); this.responseText = 'You have been on this page for ' + seconds + ' seconds...' } }); })(); </script> <div ic-src="/seconds" ic-poll="2s">You have been on this page for 0 seconds...</div> </div> </div> </div> </div>