please tell me how not to execute ajax request if respond empty?
var startFrom = 2; var count = 0; $(window).scroll(function() { if( $(window).scrollTop() + $(window).height() >= $(document).height() ){ count++; $.ajax({ url: '/index.php/posts/index/products', method: 'POST', dataType: 'json', data: {"startFrom" : startFrom, "count" : count, "categoryId": <?php echo $categoryId ?> }, success: function(response){ //console.log(response); if (response!="") { $('.products-grid').append(response); startFrom++; }else{ $('.products-grid').append(response); } } }); } });
respond- meaning the result of the ajax request, then nothing. - Grundyif (предыдущий ответ не был пуст) { $.ajax(...) }- nörbörnën