0

我正在 javascript 函数中从我的 codeigniter 视图发出 ajax 请求,但没有任何反应,并且弹出成功警报(ok)

function show_drop_downn(){
    document.getElementById("drop_downn").style.visibility = "visible"; 
    $.ajax({
        type: "POST",
        url: "http://localhost/ok/index.php/search/ajax_delete_ntify",
        success: alert('ok'),
    }); 
}

这是我的控制器,它运行完美,当我将 url(用于 ajax 请求)复制粘贴到浏览器中时,一切正常,控制器调用模型并且运行完美

function ajax_delete_ntify()
{
    echo "incontroller";
    $email=$this->session->userdata('email_of_user');
    $this->load->model('search_peoplee');
    $data['userid']= $this->search_peoplee->get_userid_from_email($email);
    foreach ($data['userid'] as $row)
    {
        $one=$row->userid;
    }
    $this->search_peoplee->delete_notifications($one);
    return;
}
4

1 回答 1

0

看法 :

function show_drop_downn(){
    document.getElementById("drop_downn").style.visibility = "visible"; 
    $.ajax({
        type: "POST",
        url: "http://localhost/ok/index.php/search/ajax_delete_ntify",
        success:function(
         console.log("success");
        )
    }); 
}

控制器 :

function ajax_delete_ntify()
{
    echo "incontroller";
    $email=$this->session->userdata('email_of_user');
    $this->load->model('search_peoplee');
    $data= $this->search_peoplee->get_userid_from_email($email);
    $res=$this->search_peoplee->delete_notifications($data[0]->userid);
    if($res){
      echo json_encode(array('success'=>true));
    }else{
      echo json_encode(array('success'=>false));
    }
}
于 2015-08-30T05:05:09.143 回答