javascript - Jquery ajax is calling multiple time on scroll -


here in below code iam calling ajax on scroll. calling ajax multiple times. restrict added settimeout function , flag (i.e. isactive) still calling 2 times.
please me iam going wrong.
in advance

var isactive = false; var sindex =12; var myflag = '1';    var offset = 12; var timeout; jquery(window).scroll(function () {   if(typeof timeout == "number") {   window.cleartimeout(timeout);   delete timeout;  } timeout = window.settimeout( check, 500); });   function check(){ var cat = $(".mi-selected").attr('id'); var tecid = $("#technologyid").val();     var notsameind = $("#notsameind").val();     var sindex =$("#startind").val(); if (!isactive &&  ($(window).scrolltop() + $(window).height() == $(document).height()) && (sindex !== notsameind) ) {    var isactive = true; jquery.ajax({               type: "post",               url: 'http://some.com/responceportfolio.php',               data: {              tecid:tecid,                   cat:cat,                   startindex:sindex,                   offset:offset,                   count_now:count_now                },               success: function (result) {             if(result !== ''){                 jquery("#loaderimage").hide();                     jquery("#portfoliolist").append(result);                 $("#notsameind").val(sindex);                     sindex = parseint(sindex) + parseint(offset);                 $("#startind").val(sindex);               }                   else{                                        jquery("#loaderimage").hide();                }             isactive = false;                },               error: function (error) {                   //alert(error);               }           });      } 

}


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -