function _query() { var _s = setInterval(function () { $.get('/...', function (data) { if (data == 1) clearInterval(_s); }); }, 1000); }
-
<a href="javascript://" onclick="_query()">test</a>
That is, if you click on the test link 3 times, then 3 setInterval is called immediately, if 10, then 10, etc.
As you can when you click on the link at least 20-30 times, call only 1 setInterval . setTimeout no need to offer.