Ajax dynamic data fetch - 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: Ajax dynamic data fetch (/showthread.php?tid=66789) |
Ajax dynamic data fetch - sheenam - 12-03-2016 Hi all, i want to fetch the data dynamically from two tables my model , view and controller are as follows VIEW PHP Code: [code][php] <div class="form-group"> // THIS IS MY SCRIPT// <script> //AJAX call for getting items for selected supplier $('select#role').change(function() { var contact_type = $(this).val(); // console.log(role); var link = '<?php echo base_url()?>'+'index.php/deals/get_contacts_ajax/'+contact_type; $.ajax({ supplier_id: contact_type, url: link }).done(function(option) { // console.log(option); if (option) { $('#assigned_to').html(option); }else{ $('#assigned_to').html('<option><?php echo get_phrase('no_record_found'); ?></option>'); }; rowOption = option; }); }); </script> [/php] CONTROLLER PHP Code: public function get_contacts_ajax($type) PHP Code: public function get_contacts_ajax($type) i have to fetch the details from roles and users in which i have to fetch role names from roles table and user-name from users with reference to role_id . i tried to do that but i am unable to get the results. i am able to get the different roles from database but how do i get the users related to that id using AJAX please help me !! Thanku in Advance. RE: Ajax dynamic data fetch - neuron - 12-03-2016 (12-03-2016, 01:26 AM)sheenam Wrote: Hi all, I think your error is here: $str = '<option value="">'.get_phrase('select').' *</option>'; instead of get_phrase('select') write $this->get_phrase('select') My advice to you is always run controller methods without ajax, test it if it work properly and then try using ajax. RE: Ajax dynamic data fetch - sheenam - 12-04-2016 (12-03-2016, 02:13 AM)neuron Wrote:(12-03-2016, 01:26 AM)sheenam Wrote: Hi all, Thanks for your reply dear. I jus want to know how can i use ajax for the two table dynamically. like i m fetching data from 2 tables and based on one drop down value the values related to that field shud come how it can be done? plz help!! RE: Ajax dynamic data fetch - InsiteFX - 12-05-2016 This may help you out. More Cascading AJAX Dropdowns with CodeIgniter RE: Ajax dynamic data fetch - sheenam - 12-05-2016 (12-05-2016, 04:05 AM)InsiteFX Wrote: This may help you out. thanku so much dear : understood a little bit may be the link u have pasted out here would make my concepts much clear. thanku so much .. |