Javascript jQuery从PHP控制器$this发送值时出现问题->;输入->;post(';id';,TRUE);
view.phpJavascript 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
$(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'));
});