//this is views file in codeigniter
$(".saving").click(function(){
var id_member = $("#code_member").val();
$.ajax({
url : '<?=site_url();?>show_joinmember/',
type : 'post',
dataType: "json",
data : {'id_member':id_member},
success : function(data){
alert(data);
}
});
});
function show_joinmember(){
$id = $this->input->post('id_member');
$qry = "select * from member where id_member = $id";
$Sql = $this->db->query($qry)->result();
foreach ($Sql as $r){
$r->value = $r->vendor_acct;
$r->id = $r->apinvoice_id;
$row_set[] = $r;
}
echo json_encode($row_set);
}
结果提醒(数据)
[object Object],[object Object],[object Object],[object 对象],[对象对象],[对象对象],[对象对象],[对象 对象],[对象对象],[对象对象],[对象对象],[对象 对象],[对象对象],[对象对象],[对象对象],[对象 对象],[对象对象]
答案 0 :(得分:0)
使用result_array()
代替result()
在
$this->db->query($qry)->result();
像这样
$Sql = $this->db->query($qry)->result_array();
foreach ($Sql as $r){
$r['value'] = $r['vendor_acct'];
$r['id'] = $r['apinvoice_id'];
$row_set[] = $r;
}
echo json_encode($row_set);