Javascript Ajax livecount不是逗号格式
如何以逗号形式显示计数?目前,即使它是千种形式,它也没有使用逗号。有什么办法可以让它工作吗?先谢谢你。我提供了下面的代码和我当前问题的屏幕截图+我的目标。提前谢谢你,祝你度过愉快的一天 HTML:Javascript Ajax livecount不是逗号格式,javascript,jquery,ajax,codeigniter,Javascript,Jquery,Ajax,Codeigniter,如何以逗号形式显示计数?目前,即使它是千种形式,它也没有使用逗号。有什么办法可以让它工作吗?先谢谢你。我提供了下面的代码和我当前问题的屏幕截图+我的目标。提前谢谢你,祝你度过愉快的一天 HTML: //// I do show my live count by triggering the id="countBalance" from my ajax script <h3 id="countBalance"><sup styl
//// I do show my live count by triggering the id="countBalance" from my ajax script
<h3 id="countBalance"><sup style="font-size: 20px"> Php</sup></h3>
<script>
function liveBalance(){
$.ajax({
url:'<?=site_url('masteragent/liveBalance')?>',
type: "POST",
dataType:"json",
success:function(data){
$('#countBalance').html(data);
}
});
}
setInterval(function(){
liveBalance()
},1000);
</script>
function liveBalance(){
$output=$this->masters->live_balance();
echo json_encode($output);
}
型号:
function live_balance(){
$reqamount= $this->session->userdata('uid');
$this->db->select('balance');
$this->db->where('maID',$reqamount);
$result = $this->db->get('prefunding_ma')->row();
return $result->balance;
}
亲爱的在你的控制器改变
echo json_encode($output);
到
使用数字方法哇,效果很好。我不知道事情这么简单。我只知道PHP中的回声号格式,但不知道ajax/script中的回声号格式。谢谢你。非常感谢。
echo json_encode(number_format($output));