Answer the question
In order to leave comments, you need to log in
Why does ajax return undefined?
There is a site - tyts
Below there is a button that loads the goods from page 2 with Ajax, the code is corny
var page = 1;
$(document).on('click', '.show-more', function(e){
e.preventDefault();
page = page+1;
$.ajax({
type: 'GET',
data:{'page':page},
beforeSend: function(){
$('.show-more').addClass('active');
},
success:function(data){
content = $(data).find('.item_ajax');
pagination = $(data).find('#pagination').html();
console.log(content);
console.log(pagination);
setTimeout(function()
{
if(content.length>0)
{
$('#content').append(content);
$('#pagination').html(pagination);
display($.totalStorage('display'));
}
else
{
$('.show-more').html('<i class="fa fa-ban" aria-hidden="true"></i>Больше нет!');
setTimeout(function()
{
$('.show-more').slideUp(350);
}, 1600);
}
$('.show-more').removeClass('active');
}, 700);
}
});
});
e.fn.init [prevObject: e.fn.init(1), context: undefined, selector: '.item_ajax']
undefined
console.log(content);
console.log(pagination);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question