i am making an ajax request in my php file, and the request is returning with correct value. But when I try to use append function in jquery it returns and erro in the console.
$.ajax({
url:"ajax.php",
type:"POST",
success:function(msg){
$("#loadMoreButton").hide();
alert(msg.length);
$.each(msg, function(index){
$(".blog-masonry").append("<div class='post-masonry col-md-4 col-sm-6'> <div class='blog-thumb'> <img src='" + msg[index].image +"' alt=""> <div class='overlay-b'> <div class='overlay-inner'> <a href='#' class='fa fa-link'></a> </div></div></div><div class='blog-body'> <div class='box-content'><h3 class='post-title'><a href='" + msg[index].external_link +"' target='_blank'>" + msg[index].title + "</a></h3><span class='blog-meta'>" + msg[index].date_pub + "</span><p>"+ msg[index].Content +"</p></div></div></div>");
});
$("#loadMoreButton").show();
},
dataType:"json",
data: {"from": ("" + id), "cat" : "<?php echo $_GET['category']; ?>"}
});
The error says SyntaxError: Expected token ')' in the line where I try to append the html.
I'm not sure what is missing here?
alt=""and it needs to be quoted:alt=\"\".