Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send the jquery array value to controller on codeigniter

i am new to codeigniter, i was created some list of records from database , my problem is if i want to delete the more record using checkbox , i was get the array value as string format from jquery, but i dont know how to send this value to controller , please tell anyone

my jquery code multi select record

$('.del_mybuyer').click(function(){
        var selected = new Array();
        var inc = 0;
        $('input.selbuyer:checked').each(function(){
                selected[inc] = $(this).attr('id'); 
            inc = inc + 1;
        })      
        tdelbuy=selected.toString();                

    })

here the tdelbuy was working fine, but i dont know how to set this in session or how to send this to my controller, please tell any one

like image 660
Kevin - Dhinesh babu Avatar asked Feb 17 '23 05:02

Kevin - Dhinesh babu


1 Answers

use $.ajax, $.post, or $.get

try this

  $.post('path/to /your/controller',{data:tdelbuy},function(html){
        alert(html);
  });    

and your controller get the posted value by

 var postedValue=$this->input->post('data'); 
 //do your stuff.
 echo "done";
like image 196
bipen Avatar answered Apr 29 '23 23:04

bipen