这是我的代码:
<script>
$(document).ready(function(){
setInterval(function(){
$.ajax({
type: 'get',
url: base_url+'main/activity_window',
dataType: 'json',
success: function(html) {
//don't know what the code here :(
}
});
},30000);
});
</script>
这是我的控制器内的代码:
function activity_window(){
$this->load->model('core_m');
$core_m = new Core_m;
$t = $core_m->get_waybill_created();
foreach($t as $result){
echo json_encode(array('name'=>$result['waybillno']));
}
}
这是我的 div/表:
<div id="put_data_here"></div>
<table id="put_data_here"></table>
这是控制器的结果:
{"name":"MAIN-0056-00000006"}{"name":"MAIN-0056-00000005"}{"name":"MAIN-0056-00000004"}{"name":"MAIN-0056-00000003 "}{"name":"MAIN-0056-00000002"}{"name":"MAIN-0056-00000001"}
如何将数据放入 div 或 table 中,如下所示:
New Waybill Entry MAIN-0056-00000006
New Waybill Entry MAIN-0056-00000005
New Waybill Entry MAIN-0056-00000004
New Waybill Entry MAIN-0056-00000003
New Waybill Entry MAIN-0056-00000002
New Waybill Entry MAIN-0056-00000001
请帮帮我..提前谢谢你先生..