• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Onchnage event fire and get id in controller using ajax

#1
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);
      

}
Reply

#2
@jaydevvara,

Try this: onchange="calculate(this.value)"
Reply

#3
(07-17-2018, 08:27 AM)php_rocs Wrote: @jaydevvara,

Try this: onchange="calculate(this.value)"

Thank You dear,I got id value in ajax but i still did not get id in controller
Reply

#4
(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.
Reply

#5
You need to use Ajax to post the id to the controller after getting it.
.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
(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 Blush
Reply

#7
(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

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.


Thank you for suggestion Blush
Reply

#8
(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

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.


Thank you for suggestion Blush
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.