Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
how to append json data to the div am having image and date,name,and message.For differnt numbers theri corresponding messages am having how to apppend in the div.help me.thankyou.

What I have tried:

$(document).ready(function() {



$(document).on("click","#msg", function(){
var json=null;
$.ajax({
async: false,
global: false,
type: "POST",
url: "http://ivr.callxl.com/CallerPopWebServices/OffLineMessages?Devicetype=web&timezone=+05:30&&companyname=gmail72256&date=2016-04-2015:49:40&role=above&noofrecords=5",
data: '',
dataType: "json",

success: function( data, textStatus, jqXHR) {
console.log(data);
json=data;
for(var i=0;i<json.length;i++)>
{


}

},
// If there was no resonse from the server
error: function(jqXHR, textStatus, errorThrown){
alert(jqXHR.responseText);
console.log("Something really bad happened " + textStatus);
$("#errorResponse").html(jqXHR.responseText);
},
});













});
});
Posted
Updated 16-Jun-16 20:43pm
Comments
Sinisa Hajnal 17-Jun-16 2:32am    
What have you tried? You show empty for loop without doing anything.

1 solution

JavaScript
var str='<table>';
for(var i=0;i<json.length;i++)>
{
 str+='<tr><td><img src="+json.image+" /></td><td>'+date+'</td><td>'+json.name+'</td><td>'+json.message+'</td><table><tbody><tr>;

}
$('#yourdivid').append(str);
</tr></tbody></table></tr></table>
 
Share this answer
 
Comments
Member 12559011 17-Jun-16 3:43am    
this is my html

<div class="panel-body">
<ul class="chat">
<li class="left clearfix" id="chatfirstid"><span class="chat-img pull-left">
<img src="images/person.png" alt="person" class="img-circle">
</span>
<div class="chat-body clearfix">
<div class="header">
Dinesh
1 June

</div>
<p>
Hii.How are you..
</p>
</div>
</li>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900