Advertisement
salmanagustian

Controller & keypress

Apr 30th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. ====================Keypres ===========================
  2.   function carianggota()
  3.         {
  4.          
  5.           $(document).on('keypress','#no_anggota',function(e){
  6.                 // console.log('barcode_sparepart_code on keypress');
  7.  
  8.                 if(e.keyCode==13){
  9.                     e.preventDefault();
  10.                      var id = $('#no_anggota').val();
  11.                 }
  12.  
  13.                  $.ajax({
  14.                         url : APP_URL+'/carianggota/'+ id,
  15.                         type: 'GET',
  16.                         dataType : 'JSON',
  17.                         async: false,
  18.                         success: function(data)
  19.                         {  
  20.                             console.log(data);
  21.                             // alert('berhasil');
  22.                             $('#nama_anggota').val(data.nama_agt);
  23.                             $('#id_anggota').val(data.id_anggota);
  24.                             $('#status').val(data.status);
  25.                             $('#no_buku').focus();
  26.                         }                
  27.                     });    
  28.                
  29.           });
  30.        }
  31.        
  32.  
  33.  
  34. =========Controller ===============
  35. public function getNoIndukAnggota($id)
  36.     {
  37.         $data = DB::table('anggotas')
  38.                 ->select('id_anggota','nama_agt','status')
  39.                 ->where('no_induk',$id)
  40.                 ->first();  
  41.         return response()->json($data);
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement