Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery post to codeigniter问题_Jquery_Codeigniter - Fatal编程技术网

jquery post to codeigniter问题

jquery post to codeigniter问题,jquery,codeigniter,Jquery,Codeigniter,好吧,这真的快把我逼疯了 我想将一个变量从jQuery发布到CodeIgniter。这是我使用的jQuery代码: jQuery调用: $.ajax({ type: 'POST', url: 'http://sandbox.dev/tmp/livesearch', data: { "query": 'q_val', output: 'json', page: CURRENT_PAGE, limit: CURRE

好吧,这真的快把我逼疯了

我想将一个变量从jQuery发布到CodeIgniter。这是我使用的jQuery代码:

jQuery调用:

$.ajax({
  type: 'POST',
    url:  'http://sandbox.dev/tmp/livesearch',
    data: {
        "query": 'q_val',
        output: 'json',
        page: CURRENT_PAGE,
        limit: CURRENT_LIMIT
    },
    timeout:    '5000',
    dataType:   'json',
    beforeSend: function() {

    },
    complete: function() {

    },
    success: function(data, textStatus) {

    },

    // We're gonna hide everything when get error
    error: function(XMLHttpRequest, textStatus, errorThrown) {

    }
});

为了便于阅读,我已经精简了代码。问题是,我最终进入了错误函数,错误代码为200。。。从我在互联网上的发现来看,这并不意味着出了什么问题。那为什么不叫成功呢?有谁有好的教程吗?

需要查看codeigniter控制器接收的内容,以及数据中假定为字符串的内容和假定为变量的内容。是否安装了firebug?当您发出请求时,firebug中该页面的响应是什么?是的,我安装了firebug。它显示我得到了错误代码为200的错误回调。jondavidjohn,我是javascript新手。您所说的字符串是我在使用post的代码示例中看到的。我猜这只是一个散列键。当我回家时,会从CodeIgniter添加控制器代码。
$(document).ready(function(){
    $('.delete').click(function(){
        $.post("http://sandbox.dev/tmp/livesearch", {'query' : "q_val", 'output' : "json", 'page' : CURRENT_PAGE, 'limit' : CURRENT_LIMIT}, function(data) {
             alert(data);
        });
    });
});