php - Adding Setinterval and clear interval to my query -


i have counter in member can add or remove number gets saved in mysql.

i using following jquery/ajax call function when member clicks on adding or removing. removing not give exact count, planning use setinterval , clearinterval. , need use set interval once, example, should query file once in 5 seconds or exact 5 seconds. below setinterval , clearinterval not seem work,

$(function () {     var checkit = function () {         $(".addid").click(function () {             var add_id = $(this).attr("id");             var datastring = 'add_id=' + add_id;             $(".add_show" + add_id).fadein(400).html('updating...');             $.ajax({                 type: "post",                 url: "num_check.php",                 data: datastring,                 cache: false,                 success: function (html) {                     $(".add_show" + add_id).html(html);                     window.clearinterval(nre);                 }             });             return false;         });     }     var nre = setinterval(checkit, 5000); }); 

advise , appreciated

you can modify ajax call -

$.ajax({             type: "post",             url: "num_check.php",             data: datastring,             cache: false,             async : false,             success: function (html) {                 $(".add_show" + add_id).html(html);                 window.clearinterval(nre);             }         }); 

with this, next ajax call not start until current 1 has been completed. should trick.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -