weixin_33713707 2014-06-17 05:29 采纳率: 0%
浏览 138

AJAX响应非常慢

I am working on PHP CodeIgniter. By clicking on customer name I call a JavaScript function customerBasic for some other purpose that also call show_cs_info that send AJAX call to controller as below.

AJAX function:

function customerBasic(customer_id,isConsumer, name )
 {
   document.getElementById('random').value = customer_id+"/"+name;
   $.ajax({
        url: site_url+"customer/connections/index/"+customer_id+"/"+0+"/"+isConsumer,
        type: 'post',
        success: function(data)
        { 

           show_cs_info(customer_id);
        }
     });

}

show_cs_info function:

function show_cs_info(id)
{
  $.ajax({
     url:site_url+"customer/customer/show_cs_info"+"/"+id+"/"+'no',
     type:'post',
     success:function(data)
     {
        $('#right_div').html(data);
     }
});
}

controller

 public function show_cs_info($id, $bit)
 {
    $id = urldecode($id);
    $bit = urldecode($bit);
    $this->load->model('customer_model');
    $data['val']= $this->customer_model->show_cs_info($id);
    $this->load->view('show_cust_info_view',$data);
 }

Model

 public function show_cs_info($id)
 {
        $this->db->where('customer_id',$id);
        $result = $this->db->get('customer_info');
        return $result->result();
 }

The AJAX call is taking 1.05s. How can I make it faster?

  • 写回答

2条回答 默认 最新

  • weixin_33739523 2015-08-04 11:47
    关注

    Actually you need to check network connection if Database server is on another server and try to remove network latency..... In other-case if you are working on local server and have web & DB server on same machine then check CPU Usage and Workload on MySQL it may be stuck due to some query...... Further upgrade your server & version of MySQL etc....

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器