Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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/2/jquery/78.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
Ajax Codeigniter更新数据库字段错误_Ajax_Jquery_Codeigniter 2 - Fatal编程技术网

Ajax Codeigniter更新数据库字段错误

Ajax Codeigniter更新数据库字段错误,ajax,jquery,codeigniter-2,Ajax,Jquery,Codeigniter 2,这是我的代码,我想更新数据库字段,但遇到错误。我打印的查询数据发布是正确的,但为什么ID=0我在db表中有资本ID,但为什么请回答我想通过ajax更新的问题。 1更新formSETst\u name='hello',st\u class='update',st\u address='SystemConfig'其中ID=0 因为id是0,所以它不更新数据,但为什么 下面是我的ajx函数 <script> $(document).ready(function() { $(

这是我的代码,我想更新数据库字段,但遇到错误。我打印的查询数据发布是正确的,但为什么ID=0我在db表中有资本ID,但为什么请回答我想通过ajax更新的问题。 1更新
form
SET
st\u name
='hello',
st\u class
='update',
st\u address
='SystemConfig'其中
ID
=0 因为id是0,所以它不更新数据,但为什么

下面是我的ajx函数

   <script>
  $(document).ready(function() {

  $(".Update").fancybox({
    'transitionIn'  :   'fade',
    'transitionOut' :   'fade',
    'speedIn'       :   600, 
    'speedOut'      :   200, 
    'overlayShow'   :   false
});
var Id = $(this).attr("id");
var parent = $(this).parent();  
  $("#updateform").bind("submit", function() {
     $.ajax({
        type        : "POST",
        cache       : false,
        url     : "http://localhost/testproj/index.php/form/update",
        data        : $(this).serializeArray(),
            success:function(data){
                $.fancybox(data);
            }
    });


    return false;
  });

  });     

$(文档).ready(函数(){
$(“.Update”).fancybox({
“transitionIn”:“fade”,
“transitionOut”:“fade”,
“speedIn”:600,
“加速输出”:200,
“叠加显示”:错误
});
var Id=$(this.attr(“Id”);
var parent=$(this.parent();
$(“#updateform”).bind(“submit”,function(){
$.ajax({
类型:“POST”,
cache:false,
url:“http://localhost/testproj/index.php/form/update",
数据:$(this).serializeArray(),
成功:功能(数据){
$.fancybox(数据);
}
});
返回false;
});
});     

**视图**


信息: 行动 --挑选-- 插入 更新 删除 行动 --挑选-- 交易 经营管理 费率 系统配置 顺从 用户管理 在线发件人管理 更新

信息:

就下列事项采取行动: --挑选-- 插入 更新 删除

行动方: --挑选-- 交易 经营管理 费率 系统配置 顺从 用户管理 在线发件人管理



身份证件: 信息: 就下列事项采取行动: 诉讼人 行动 **模型** 公共功能提交更新的数据($id,$data) { $this->load->database(); $this->db->where('ID',$ID); $query2=$this->db->update('form',$data); } **控制器** 公共功能更新() { $id=$this->input->post('id'); $name=$this->input->post('name'); $action=$this->input->post('action'); $actionBy=$this->input->post('actionBy'); $data=数组( “st_name”=>$name, “st_class”=>$action, “st_地址”=>$actionBy ); $this->form\u model->submit\u updated\u data($id,$data); $this->index(); } 1更新`form`SET`st\U name`='hello',`st\U class`='update',`st\U address`='SystemConfig',其中`ID`=0
我认为这是因为您没有提交要在$\u POST数组中更新的记录的ID

提交的所有数据都是从表单输入构建的数组,但您没有用于“id”的数组…因此:

$id=$this->input->post('ID');

…没有从表单中获得任何信息。

我认为这是因为您没有提交要在$\u POST数组中更新的记录的ID

提交的所有数据都是从表单输入构建的数组,但您没有用于“id”的数组…因此:

$id=$this->input->post('ID');

…没有从表单中获得任何信息。

模型和控制器也在上面的代码中。请回答。如何传递id?但它显示id为0为什么?如果我在模型查询中硬编码id,那么它只更新该id的数据。查询或ajax函数有问题吗?下面是查询结果(1更新表单集st_name='hello',st_class='update',st_address='SystemConfig',其中ID=0)检查您的输入数据:print\r($this->input->post(null))模型和控制器也在上面的代码中。请回答。如何传递ID?但它显示ID为0为什么?如果我在模型查询中硬编码id,那么它只更新该id的数据。查询或ajax函数有问题吗?下面是查询结果(1更新表单集st_name='hello',st_class='update',st_address='SystemConfig',其中ID=0)检查您的输入数据:print\r($this->input->post(null))