Append() не работает!
не выводит на страницу, данные все получены
<script>
// load more page->listing js
$(document).ready(function() {
var inProgress = false;
var apl = 9;
$(window).click(function() {
if ($(window).scrollTop() + $(window).height() >= $(document).height() && !inProgress) {
$.ajax({
url: 'new.php',
method: 'POST',
data: { 'apl': apl },
beforeSend: function() {
inProgress = true;
}
}).done(function(data) {
data = jQuery.parseJSON(data);
if (data.lenght > 0) {
$.each(data, function(index, data) {
$('#articles').text("<p>" + data.name + "</p>");
});
inProgress = false;
apl += 9;
}
});
}
});
});
</script>
Ответы (1 шт):
Автор решения: Igor
→ Ссылка
console.log(typeof data, data);
data = jQuery.parseJSON(data);
//if (data.lenght > 0) {
if (data.length > 0) {
$.each(data, function(index, data) {
$('#articles').append("<p>" + data.name + "</p>");
});