Syehaji93

Ajax passing data to another pages

Jan 22nd, 2023
1,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.36 KB | Software | 0 0
  1. <!-- sintaks di view -->
  2. <table id="table_picking" class="table table-bordered table-striped">
  3.     <thead>
  4.         <tr align="center">
  5.             <th>Production</th>
  6.             <th>Product ID</th>
  7.             <th>Product Name</th>
  8.             <th>Lot</th>
  9.             <th>Cost Center</th>
  10.             <th>Operation Number</th>
  11.             <th>Delivery</th>
  12.             <th>Journal</th>
  13.             <th>Operation Name</th>
  14.             <th>Status</th>
  15.             <th>Action</th>
  16.         </tr>
  17.     </thead>
  18.     <tbody>
  19.        
  20.     </tbody>
  21.    
  22. </table>
  23. <div class="card-body">
  24.            
  25.               <!-- Tabel data -->
  26.               <p class="card-text view_picking">
  27.            
  28.               </p>
  29.  
  30.             </div>
  31.             <!-- /.card-body -->
  32. <script>
  33.     function listdatapicking()
  34.     {
  35.         var table = $('#table_picking').DataTable({
  36.             "processing": true,
  37.             "serverSide": true,
  38.             "order": [],
  39.             "ajax":{
  40.                 url: "<?= site_url('picking/listdata') ?>",
  41.                 type: "POST"
  42.             },
  43.             "columnDefs": [{
  44.                 "targets": 0,
  45.                 "orderable": false
  46.             }],
  47.             "scrollX": true
  48.         });
  49.     }
  50.  
  51.     $(document).ready(function(){
  52.         listdatapicking();
  53.      
  54.     });
  55.  
  56.     function check(pl_unix)
  57.     {
  58.         $.ajax({
  59.             type: "post",
  60.             url: "<?= site_url('picking/check') ?>",
  61.             data: {
  62.                 pl_unix: pl_unix
  63.             },
  64.             dataType: "json",
  65.             success: function(response){
  66.                 console.log(response.res);
  67.                 if(response.res)
  68.                 {
  69.                     $('.view_picking').html(response.res);
  70.                    
  71.                 }
  72.             },
  73.             error: function(xhr, ajaxOptions, thrownError) {
  74.                 alert(xhr.status + "\n" + xhr.responseText + "\n" + thrownError);
  75.             }
  76.         });
  77.     }
  78. </script>
  79.  
  80. //controller
  81.     public function checkPage()
  82.     {
  83.         if($this->request->isAJAX())
  84.         {
  85.             $pl_unix = $this->request->getVar('pl_unix');
  86.  
  87.             // $row = $this->m_picking_data->find($pl_unix);
  88.             $row = $this->m_picking_data->where('pl_unix', $pl_unix)->first();
  89.             // $unix = $row['pl_unix'];
  90.  
  91.             $data = [
  92.                 // 'header' => 'Picking',
  93.                 // 'heading' => 'Double Check Picking',
  94.                 'unix'   => $row['pl_unix'],
  95.                 'production' => $row['pl_production'],
  96.                 'product_id' => $row['pl_product_id'],
  97.                 'product_name' => $row['pl_product_name'],
  98.                 'lot_control'    => $row['pl_lot_control'],
  99.                 'cost_center'    => $row['pl_cost_center'],
  100.                 'operation_number'   => $row['pl_operation_number'],
  101.                 'delivery'          => $row['pl_delivery'],
  102.                 'tf_journal'        => $row['pl_tf_journal'],
  103.                 'operation_name'    => $row['pl_operation_name'],
  104.                 'result'            => $row['dt_result']
  105.             ];
  106.  
  107.             $msg = [
  108.                 'res' => view('Picking/cek', $data)
  109.             ];
  110.            
  111.             echo json_encode($msg);
  112.            
  113.         }else{
  114.             exit('Maaf request tidak dapat diproses!');
  115.         }
  116.     }
Advertisement
Add Comment
Please, Sign In to add comment