Ajax get请求返回整个页面而不是控制器方法

时间:2014-09-02 14:27:28

标签: php jquery codeigniter

我编写一个脚本来轮询一个mysql表但不返回该方法所具有的内容,它返回整个页面html页面调用ajax

这是我的ajax

var base_url = '<?php base_url('index.php / enterprise / poll_send_q '); ?>';
/**
    Send Queue Poll
*/
window.setInterval(function() {
    $.ajax({
        type: "GET",
        url: base_url,
        success: function(data) {
            $('#send_q_poll').text(data);
        }
    });
}, 3000);

这是我的控制器方法

 public function poll_send_q(){
  if (!$this->ion_auth->logged_in()) {
                redirect('enterprise/derEintrag');
  }
  $le_current_logged_in = $this->ion_auth->get_user_id(); 
  $this->db->where('user_id', $le_current_logged_in);
  $this->db->from('send_q');
  $all = $this->db->count_all_results();
  echo $all;
}

脚本没有从控制器方法返回行数的原因是什么?。

1 个答案:

答案 0 :(得分:0)

你错过了回声

var base_url = '<?php echo base_url('index.php/enterprise/poll_send_q'); ?>';