Ajax请求没有使用编码器的响应


Ajax request no response using codeigniter

任何人都可以帮助我这个简单的代码,我有一个按钮,其中当用户提交它将加载一个javascript,将调用ajax请求只是更新我的表中的一个字段,所以我传递了一个控制器,执行此方法到我的ajax请求,但什么也没有发生。这是我的观点

 <!--body part--->
  echo "<button class='btn btn-info dropdown-toggle notify-btn' data-toggle='dropdown' 'href='#' value=".$count." onclick='notify(".$count.")'>".$count."</button>"; 
 <!--Here is my javascript--->
 function notify(count){
            $.ajax({
            type: 'POST',
           url:<?php echo base_url("notifications/set")?>,
        success:function(response){
            alert("Success");
        }
     });
            }
<!--Here is my Controller--->
     class Notifications extends CI_Controller{
     public function __construct()
     {
      parent::__construct();
      $this->load->model('notification_model');
     }
      public function index(){ 
         $this->set();
          }
        public function set(){
              $this->notification_model->set_notifications();
         }
<!--Here is my Model--->
 <?php class Notification_model extends CI_Model { 
            function set_notifications(){
                $this->db->where('notification_status','active');
                $this->db->set('notification_status',"inactive",FALSE);
                $this->db->update('messages');
            }
        }
?>

从快速查看来看,您的AJAX请求可能失败,因为您的URL没有用单引号括起来。尝试以下操作(注意URL周围的单引号):

function notify(count){
    $.ajax({
        type: 'POST',
        url: '<?php echo base_url("notifications/set"); ?>',
        success:function(response){
            alert("Success");
        }
    });
}