I'm making a JSON call and receiving data and inputting the data received into some HTML. However I don't think this is the best way to return the data. It's seems like a bit of a hack as I'm injecting a bunch of HTML in my jQuery. I'm also adding an image inside of my jQuery cause I want it to appear between some of the JSON data that is getting returned. Ideally I'd like my html to loop through and generate this info into the chatInfo
div. Anybody have any ideas how to better do this?
$.getJSON("/services/chatInfo.json?user=manual" + mediaTypes + locationTypes, function(data) {
var items = [];
$.each( data.media, function( key, val ) {
items.push( "<div class='chatInfo'><h6 id='" + key + "'>" + val.displayName + "</h6>" );
items.push( "<aside><img src='/google.png'></aside><p>" + val.hours + "</p></div>" );
});
$("<div>").html(items.join("")).appendTo( "#chatInfo" );
});