Im pulling a JSON result from MYSQL using JQUERY.
Im then displaying the result in a loop in order to fill a UL list.
var auto_refresh = setInterval(
function ()
{
url='<?php echo base_url(); ?>index.php/chat/comments/';
$.getJSON(url , function(data) {
var tbl_body = "";
$.each(data, function() {
var tbl_row = "";
$.each(this, function(k , v) {
tbl_row += ""+v+"";
})
tbl_body += "<li>"+tbl_row+"</li>";
})
$("#table1").html(tbl_body);
});
}, 1000);
This displays the results as
CommentName
I want to have the Name in italics and the comment in plain text like
Comment – Name
How would i go about seperating the name from the comment so i can make it italic?
Cheers
You can probably do this :
or
But it’s hard to guess without the JSON structure (probably an array and not an object because with a plain object there would be risks about the iteration order).