PHP CODE:
echo json_encode($data);
JQUERY AJAX:
$(".comment").click(function(){
var id = $(this).data("id");
var name = $("#username_"+id).val();
if(name=='') {
alert("Please Fill All Fields");
} else {
$.ajax({
type: "POST",
url: "comments",
data:{comments:name,parent:id},
dataType: 'json',
success: function(json) {
json.forEach(function (item, index){
var br = "<br>";
var url = "http://localhost/projects/quotes/assets/uploads/avatar/";
$(".cmt_comments img").append(""+url+item.image+"");
$(".cmt_comments").append(item.comments,br);
});
}
});
}
});
JSON ARRAY:
[{"image":"1510553363_User_Avatar_2.png","comments":"NICE"}]
HTML:
<div class="cmt_comments">
<img src="" alt="">
</div>
OUTPUT:
NICE
I want:
Now display only image url. how to i display image