c# - Ajax call back function called always after first call -
i want auto load using ajax call function getdata
function keep being called after first same parameters. here javascript codes:
var currentpage = 0; var isfinished = false; var lastscrolltop = 0; $(window).data('ajaxready', true).scroll(function (e) { if ($(window).data('ajaxready') == false) return; $(window).scroll(function (event) { var st = $(this).scrolltop(); if (st > lastscrolltop) { if (st > window.innerheight) { var amountvalue = $("#amount").val(); var firstprice = 0; var lastprice = 10000; infinitescroll(firstprice, lastprice); } } }); }); function infinitescroll(firstprice, lastprice) { if (firstprice < 0 || firstprice == undefined) { firstprice = 0; } if (lastprice < 0 || lastprice == undefined) { lastprice = 10000; } if (isfinished) { return; } $('#divpostsloader').html('<img src="images/loader.gif">'); var rawpath = window.location.pathname.split('/'); var categoryid = rawpath[rawpath.length - 1]; $("#load").show(); $.ajax({ type: "post", url: "http://localhost:60579/ajaxcallpage.aspx/getdata", data: "{categoryid:" + categoryid + ",page:" + currentpage + ",skip:'9',firstprice:" + firstprice + ",lastprice:" + lastprice + "}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) { if (data.d.length < 3) { isfinished = true; } var products = json.parse(data.d); $.each(json.parse(data.d), function () { // ... smth.. }); currentpage += 1; $("#load").hide(); } }); };
i don't scroll down calls getdata
function after first call. have suggesiton?
the problem here:
if (st > lastscrolltop) { if (st > window.innerheight) {
check out because reason entering in part of function without scrolling. if have time take look.
Comments
Post a Comment