到达CI控制器后,AJAX post值变为boolean

时间:2015-08-28 17:33:18

标签: ajax codeigniter

我一直在谷歌搜索几天但仍无法解决这个问题。我有这个ajax函数,它更新mysql数据库中的记录。当我使用ajax插入新记录时,一切都很顺利,但当我通过ajax更新此记录时,它给了我403 Forbidden响应。当我使用var_dump检查从ajax传递的值时,所有值都变为boolean。以下是我的代码,希望你能帮助我。

Ajax更新

$.ajax({
    url:'updateDeal',
    async:false,
    type:'post',
    data:{
        dealId:dealId,
        dealName:dealName,
        dealLocation:dealLocation,
        dealCategory:dealCategory,
        dealDescription:description,
        dealValidDate:dealValidDate,
        dealRegularPrice:dealRegularPrice,
        dealPromoPrice:dealPromoPrice,
        dealHighlights:tourHighlight,
        dealInclusion:inclusions,
        dealItenerary:itinerary,
        dealAdditionalServices:additional,
        isPromo:isPromo,
        isPublish:isPublish
    },
    beforeSend: function(){
        $('.image-loader').show();
    },
    success:function(results){
        var obj = $.parseJSON(results);
        if(!obj.hasError){
            $('.image-loader').hide();
            window.location = 'success?id=2';
        }
    }
});

位指示

public function updateDeal(){

        $data = array(
            "Id"                    => $this->input->post('dealId'),
            "dealName"              => $this->input->post('dealName'),
            "dealLocation"          => $this->input->post('dealLocation'),
            "dealCategory"          => $this->input->post('dealCategory'),
            "dealDescription"       => $this->input->post('dealDescription'),
            "dealValidDate"         => $this->input->post('dealValidDate'),
            "dealRegularPrice"      => $this->input->post('dealRegularPrice'),
            "dealPromoPrice"        => $this->input->post('dealPromoPrice'),
            "dealHighlights"        => $this->input->post('dealHighlights'),
            "dealInclusion"         => $this->input->post('dealInclusion'),
            "dealItenerary"         => $this->input->post('dealItenerary'),
            "dealAdditionalServices" => $this->input->post('dealAdditionalServices'),
            "isPromo"               => $this->input->post('isPromo'),
            "isPublished"           => $this->input->post('isPublish')
        );
        var_dump($data);

    }

RESULT

array(14) {
  ["Id"]=>
  bool(false)
  ["dealName"]=>
  bool(false)
  ["dealLocation"]=>
  bool(false)
  ["dealCategory"]=>
  bool(false)
  ["dealDescription"]=>
  bool(false)
  ["dealValidDate"]=>
  bool(false)
  ["dealRegularPrice"]=>
  bool(false)
  ["dealPromoPrice"]=>
  bool(false)
  ["dealHighlights"]=>
  bool(false)
  ["dealInclusion"]=>
  bool(false)
  ["dealItenerary"]=>
  bool(false)
  ["dealAdditionalServices"]=>
  bool(false)
  ["isPromo"]=>
  bool(false)
  ["isPublished"]=>
  bool(false)
}

2 个答案:

答案 0 :(得分:0)

我认为在发送ajax请求时,网址上存在一些混淆。

在ajax请求中尝试:

url : 'yourcontrollername/updateDeal';

答案 1 :(得分:0)

我已经解决了我的问题,mod_security继续阻止参数。谢谢