Ajax dynamic data fetch |
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. (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. (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!!
This may help you out.
More Cascading AJAX Dropdowns with CodeIgniter What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(12-05-2016, 04:05 AM)InsiteFX Wrote: This may help you out. thanku so much dear : ![]() ![]() |
Welcome Guest, Not a member yet? Register Sign In |