![]() |
Onchnage event fire and get id in controller using ajax - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Onchnage event fire and get id in controller using ajax (/showthread.php?tid=71186) |
Onchnage event fire and get id in controller using ajax - jaydevvara - 07-17-2018 Hello guyz i need help in ajax when onchange event fire in dropdown i want the value in controller but i did not get it Here is mu code: VIEW: <select name="user_role" id="user_role" onchange="calculate(this)"> <option>--Select User--</option> <?php foreach ($roll_get as $roll) { ?> <option value="<?php echo $roll->user_id; ?>" id="<?php echo $roll->user_id; ?>"><?php echo $roll->full_name; ?></option> <?php } ?> </select><br> AJAX: function calculate(id) { var id=id; $.ajax({ type:'POST', url:'welcome/user_manager', data:{'id':id}, success:function(data){ } }); } CONTROLLER: public function user_manager() { $id=$this->input->post('id',true); } RE: Onchnage event fire and get id in controller using ajax - php_rocs - 07-17-2018 @jaydevvara, Try this: onchange="calculate(this.value)" RE: Onchnage event fire and get id in controller using ajax - jaydevvara - 07-17-2018 (07-17-2018, 08:27 AM)php_rocs Wrote: @jaydevvara, Thank You dear,I got id value in ajax but i still did not get id in controller RE: Onchnage event fire and get id in controller using ajax - Pertti - 07-17-2018 (07-17-2018, 09:18 PM)jaydevvara Wrote: Thank You dear,I got id value in ajax but i still did not get id in controller If you use Chrome you can use developer tools Network tab to see if the AJAX request throws an error or not, makes it easier to debug AJAX requests that happen behind the scenes. RE: Onchnage event fire and get id in controller using ajax - InsiteFX - 07-18-2018 You need to use Ajax to post the id to the controller after getting it. . RE: Onchnage event fire and get id in controller using ajax - jaydevvara - 07-18-2018 (07-18-2018, 03:48 AM)InsiteFX Wrote: You need to use Ajax to post the id to the controller after getting it. Thank you for suggestion ![]() RE: Onchnage event fire and get id in controller using ajax - jaydevvara - 07-18-2018 (07-17-2018, 11:31 PM)Pertti Wrote:(07-17-2018, 09:18 PM)jaydevvara Wrote: Thank You dear,I got id value in ajax but i still did not get id in controller Thank you for suggestion ![]() RE: Onchnage event fire and get id in controller using ajax - jaydevvara - 07-18-2018 (07-17-2018, 11:31 PM)Pertti Wrote:(07-17-2018, 09:18 PM)jaydevvara Wrote: Thank You dear,I got id value in ajax but i still did not get id in controller Thank you for suggestion ![]() |