【问题标题】:$.post is looking into the base url instead of the url given as parameter$.post 正在查看基本 url,而不是作为参数给出的 url
【发布时间】:2019-12-04 17:14:42
【问题描述】:

从 show_by_filter() 调用 filter_propert():

function show_by_filter(){
  var data = removed_code;
  $.post(" http://studentssaathi.com/application/controllers/Clients.php/filter_property",data, function(response) {
    $('.columns').html("");
    $('.columns').html(response);
   });
}

show_by_filter 位于 assets/users/js/users.js 中

出现错误:jquery.min.js:4 POST http://studentssaathi.com/filter_property 404(未找到)

我不明白它为什么要在基本 url 中寻找函数。

控制器代码(Clients.php):

public function filter_property(){
    $post_req = $this->input->post();
    $search_name = $post_req['search_name'];
    $filter_price = $post_req['price'];
    unset($post_req['search_name']);
    unset($post_req['price']);

    $result = $this->user_model->get_property_details($post_req, $search_name, $filter_price);
    $data = array();
    $data['result'] = $result;
    $this->load->view('users/login/home_content', $data);
}

【问题讨论】:

  • 应该是 $.post('/controller/method/argument',d,f(r){})
  • @Vickel 你可以为我的用例设计它吗?
  • 你的控制器是什么?客户端.php?以及您要运行的方法?过滤器属性()?如果是这样,你应该写$.post('/clients/filter_property',data,function(r){})
  • 嗨 @RahulKumar 不确定它是否有帮助,我在想可能传递给 $.post 的数据需要像 { myData: data} 这样的对象包装,你能检查一下吗?
  • @Vickel 试过了,没有运气。

标签: php jquery codeigniter


【解决方案1】:

我做了$.post("clients/filter_property/",data, function(response) { $('.columns').html(""); $('.columns').html(response); });

它现在可以工作了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 2016-02-04
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    • 1970-01-01
    相关资源
    最近更新 更多