Answer the question
In order to leave comments, you need to log in
Ajax requests not working why?
I want to make an ajax request, but I go to the console and it **** swears "Uncaught SyntaxError: Unexpected token < " Swears on lists, why? Or am I writing something wrong?
$(document).ready(function(){
var num = 20;
var inProcess = false;
$(window).scroll(function(){
if ($(window).scrollTop() + $(window).height >= $(document).height() && !inProcess ){
$.ajax({
url: 'load.php',
method: 'GET',
data: {"num" : num},
beforeSend: function(){
inProcess = true;
}
}).done(function(data){
console.log(data);
data = jquery.parseJSON(data);
if (data.legth > 0) {
$.each(data, function(index, data){
$(".videos") .append("
div class="videos_image"
a href="pagevideo/"img src="/media/images/" + data.image + " width="250" height="180" / /a
div
div class="videos_title">" + data.title + "div
div class="videos_views" p Просмотров:" + data.views" p div
li
ul
");
});
inProcess = false;
num += 10;
}
});
}
});
});
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