title: Pass Javascript Variables tp PHP Controller in Code Igniter
body: <p>Hi everyone I have this javascript that has to pass some variables including an array. My problem is that I cannot pass these values using the uRL because i might deal with many values. I am trying to use ajax JSON but i just cannot retrieve the values: Here is my javascript:</p>
  
  <pre><code>$(function(){
        $('#preview').click(function(){
           var thesum=0;
           var rowid=[];
           var rowfields=[];
               var supplier = document.getElementById("sid").value; //need to pass
               var terms=document.getElementById("terms").value; //need to pass
  
               var count = ($('#listOfProducts tr').length);
               //loop start
                  var i=0;
                  grid=$('#listOfProducts input[type="checkbox"]:checked').each(function(){
                  var $row = $(this).parents('tr'); 
                  var $trid =$(this).closest('tr').attr('id');
                  rowid[i]=$trid; 
                      rowfields.push({itemname: $row.find('td:eq(0)').text(), productname:$row.find('td:eq(1)').text(), productdesc: $row.find('td:eq(2)').text(), unitprice:$row.find('td:eq(3)').text(), quantity:$row.find('td:eq(5) input').val(), amount:$row.find('td:eq(6) input').val()});
                      i++;
                  });//each close 
                  var $tbldata=JSON.stringify(rowfields);//need to pass
                  window.location = '&lt;?php echo base_url();?&gt;index.php/main/retrievepo';// this is where i should get the passeddata
      });//preview click close
   });//function close
  </code></pre>
  
  <p>Here is my function, located in a PHP Controller (i am  using codeigniter) </p>
  
  <pre><code>public function retrievepo()
  {
  // should recieve data here
  $this-&gt;load-&gt;view('PurchaseOrderPreview');
  }
  </code></pre>
  
  <p>Any help please? I've been stacked from here for so long...</p>