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

编程入门 行业动态 更新时间:2024-10-15 16:20:15
本文介绍了到达CI控制器后,AJAX post值变为boolean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在谷歌搜索几天但仍无法解决这个问题。我有这个ajax函数,它更新mysql数据库中的记录。当我使用ajax插入新记录时,一切都很顺利,但当我通过ajax更新此记录时,它给了我403 Forbidden响应。当我使用var_dump检查从ajax传递的值时,所有值都变为boolean。下面是我的代码,希望你能帮帮我。 AJAX $。ajax({ url:' updateDeal', async: false ,类型:' post',数据:{ dealId:dealId, dealName:dealName, dealLocation:dealLocation, dealCategory:dealCategory, dealDescription:description, dealValidDate: dealValidDate, dealRegularPrice, dealPromoPrice:dealPromoPrice, dealHighlights:tourHighlight, dealInclusion:inclusions, dealItenerary:行程, dealAdditionalServices:附加, isPromo:isPromo, isPublish:isPublish }, beforeSend: function (){ $(' .image-loader')。show(); },成功:功能(结果){ var obj = $ .parseJSON(results); if (!obj.hasError){ $(' 图像加载器)隐藏(); window 。 location = ' success?id = 2'; } } });

控制器

公共函数updateDeal(){ $ data = array( Id => $ this-> input-> post(' dealId'), dealName => $ this-> input-> post(' dealName'), dealLocation => $ this-> input-> post(' dealLocation'), dealCategory => $ this-> input-&g t; 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); }

结果 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)}

解决方案

.ajax({ url:' updateDeal', async: false ,类型:' 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(); },成功:功能(结果){ var obj =

.parseJSON(results); if (!obj.hasError){

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

$.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

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

解决方案

.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){

更多推荐

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

本文发布于:2023-10-11 14:11:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1481933.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   CI   AJAX   boolean   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!