Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.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

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
Javascript jQuery从PHP控制器$this发送值时出现问题->;输入->;post(';id';,TRUE);_Javascript_Codeigniter - Fatal编程技术网

Javascript jQuery从PHP控制器$this发送值时出现问题->;输入->;post(';id';,TRUE);

Javascript jQuery从PHP控制器$this发送值时出现问题->;输入->;post(';id';,TRUE);,javascript,codeigniter,Javascript,Codeigniter,view.php $(document).ready(function() { $('.buttons > a').livequery("click",function(e){ var parent = $(this).parent(); var getID = parent.attr('id').replace('button_',''); var url = '<?php echo site_url('cart/p

view.php

$(document).ready(function() { 
    $('.buttons > a').livequery("click",function(e){
        var parent  = $(this).parent();
        var getID   =  parent.attr('id').replace('button_','');
        var url = '<?php echo site_url('cart/price');?>';
        $.post(url+"?id="+getID, {}, function(response){
            $('#button_'+getID).html($(response).fadeIn('slow'));
        });
    }); 
});

<span class="buttons" id="button_5"><a class="btn-following" href="javascript: void(0)"></a></span>
型号:

function following($gid){       
    mysql_query("INSERT INTO tf_followers (following_id) VALUES('".$gid."')");        
}

从这里,我得到了数据库的空值,这是通过jQuery传递值的正确方法。

如果您想正确地将数据传递到
$。post
,请使用其3个参数重载:

$.post(url, {id: getID}, function(response){
    $('#button_'+getID).html($(response).fadeIn('slow'));
});

如果您想用GET(像以前一样)传递它,就不能在服务器上的POST变量集合中获取它。

如果您想用这种方式传递变量,只需使用$.POST(url+“/”+getID。。。
$.post(url, {id: getID}, function(response){
    $('#button_'+getID).html($(response).fadeIn('slow'));
});