My Django app sends through AJAX POST/GET communications arrays representing parts of my DB. As you can see on the picture, this is a typical array with all the objects. The objects represent a messages to integrate in a chat box. Just to clarify, the amount of objects might vary, so I need a loop function or smthg to display all the objects within the response array .
Therefore, I need to display these arrays, combining HTML and JS.
This is my exact AJAX Json response
HTML:
<div id="display"></div>
JS:
<script>
$(document).ready(function(){
setInterval(function(){
$.ajax({
type: 'GET',
url : "/checkview",
success: function(response){
console.log(response);
$("#display").empty();
for (var models_to_return in response.message)
{
var temp="<div class='container darker'><b>"+response.messages[models_to_returney].user_id+"</b><p>"+response.messages[models_to_return].room+"</p><span class='time-left'>"+response.messages[models_to_return].datetime+"</span></div>";
$("#display").append(temp);
}
},
error: function(response){
//alert('An error occured')
}
});
},1000);
})
</script>
But nothing is displaying.