您好我有使用codeigniter框架开发的这个消息传递线程。我使用的消息线程是使用json_encode的ajax。我的问题是我希望我回复它的每条消息都会像每3秒一样加载到页面。每次当我在firebug中看到控制台时我回复消息时,消息都被编码了。例如
{"Status":"ok","message":["admin","admin","dfddfddfdfd","d6eea1237219e4ecfba4edfb04b3c467.jpg"]}
我想要&#34;消息&#34;显示在<div>
容器
以下是我的代码。
$this->data['getThreadMessage'] = $this->mm->getThreadMessage($uri);
$this->data['firstName'] = "";
$this->data['lastName'] = "";
$this->data['message'] = "";
$this->data['photo'] = "";
foreach($this->data['getThreadMessage'] as $thread) {
$this->data['firstName'] = $thread->firstName;
$this->data['lastName'] = $thread->lastName;
$this->data['message'] = $thread->message;
$this->data['photo'] = $thread->photo;
}
$response1 = array(
'Status'=>'ok',
'message'=> array(
$this->data['firstName'],
$this->data['lastName'],
$this->data['message'],
$this->data['photo']
)
);
if($this->input->get('ajax') == "successMsg") {
echo json_encode($response1);
exit;
}
和我在视图页面中的jquery代码
<script type="text/javascript">
var autoLoad;
$(document).ready(function(){
autoLoad = setInterval(function(){loadAjax();}, 3000);
});
function loadAjax(){
$.ajax({
type: "get",
url: $(this).data("href"),
dataType: "JSON",
data: {
ajax: "successMsg"
},
success: function(data){
$(".tick").html(data.message);
}
});
}
</script>
<div >
<?php foreach($getThreadMessage as $thread): ?>
<div class="tick conversation-item item-right clearfix">
<div class="conversation-user">
<img src="<?php echo base_url();?>assets/images/small_empty_image.png" alt=""/>
</div>
<div class="conversation-body">
<div class="name">
<?php echo ucwords($thread->firstName); ?> <?php echo ucwords($thread->lastName); ?>
</div>
<div class="time hidden-xs">
<?php echo date('M d, Y', strtotime($thread->dateUpdated)); ?>
<?php echo date('H:i a', strtotime($thread->dateUpdated)); ?>
</div>
<div class="text">
<?php echo $thread->message;?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
这里发生的是每次我回复邮件时,整个邮件都会被覆盖。我怎么能这样做?任何帮助都非常感谢。 TIA