jQuery从PHP控制器发送值的问题$this->input->post('id', TRUE);.
Issues with jQuery sending value from PHP controller $this->input->post('id', TRUE);
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>
控制器:
$gid = $this->input->post('id', TRUE);
$this->Product_model->following($gid);
型:
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变量集合中获取它。
相关文章:
- 如何在angularJS中编辑时,如果DB中的值为true,则设置复选框,如果值为false,则取消选中复选框
- 正在将base64 jpeg从input-type=file上传到服务器
- AngularJS-使用'true'属性
- JavaScript-切换“;全部检查”;复选框true/false
- location.reload(true)崩溃浏览器选项卡
- 指令的模板必须只有一个根元素:With restrict E&替换true
- 如何使用input-tage上传图片并查看在laravel中上传的文件预览
- JavaScript:只有当数组中的所有项都为true时才执行函数
- 对于loop.if-仅在经过所有间隔后返回true
- if(foo!==null)的计算结果为true,即使foo为null
- ngIf的计算结果始终为true
- $(input[]).仅在firefox中出现每个抛出语法错误
- 我如何在INPUT TEXT中使用这个Javascript和jQuery
- 如果函数返回True,则显示Javascript按钮
- (false==false==true)怎么可能是真的
- 在input.checked=true/false _without_ jQuery上触发一个事件
- RexExp@JS:为什么/[INPUT|TEXTAREA]/.test(“DIV”)传递TRUE
- 如何检查“;elem.input.value==true”;
- Angularjs : make input = null when ng-hide = true
- jQuery从PHP控制器发送值的问题$this->input->post('id', TRUE);.