Click here to Skip to main content
15,886,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I been searching in google for days but still got no answer to solve this. I have this ajax function which update a record in mysql database. When I use ajax to insert a new record, everything is smooth but when I update this record thru ajax it gives me 403 Forbidden response. When I use var_dump to check the values pass from ajax all values became boolean. Below is my code, hope you can help me.

AJAX
JavaScript
$.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';
        }
    }
});


Controller

PHP
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)
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900