Advertisement
Guest User

Untitled

a guest
Jan 27th, 2018
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1.  
  2. function exibirAulas() {
  3.  
  4. var pesquisa = $('#pesquisa').val();
  5.  
  6. $.ajax({
  7. url:'http://localhost/estoque/usuario/pegar_aulas',
  8. type:'POST',
  9. data:{pesquisa:pesquisa},
  10. dataType:'json',
  11. success:function(json) {
  12. var html = '';
  13.  
  14.  
  15. if(isEmpty(json)) {
  16. $("#dataUsuario").html('Dados não encontrados!');
  17. return false;
  18. }
  19.  
  20. for(var i in json) {
  21.  
  22. if(json.status != 1) {
  23. html += '<tr class="table-danger">';
  24. } else {
  25. html += '<tr>';
  26. }
  27.  
  28. html +='<td>'+json.email+'</td>'+
  29.  
  30. '<td>'+'<img class="img img-thumbnail rounded imguserlist"'+ 'src=../assets/images/'+json.foto+'></img> </td>'+
  31.  
  32. '<td>'+json.status+'</td>'+
  33. '<td>'+json.datainclusao+'</td>'+
  34. '<td class="text-center">'+
  35. '<a class="btn btn-outline-primary" href="editar/'+json.id+'">Editar</a>'+
  36. '<a class="btn btn-outline-danger" href="excluir/'+json.id+'">Excluir</a>'+
  37. '<a class="btn btn-outline-success" href="listar/'+json.id+'">Visualizar</a>'+
  38. '</td>'+
  39. '</tr>'
  40. }
  41.  
  42. $("#dataUsuario").html('<table class="table table-bordered table-hover text-center">'+
  43. '<thead class="thead-inverse text-center">'+
  44. '<tr>'+
  45. '<th class="text-center">E-mail</th>'+
  46. '<th class="text-center">Foto</th>'+
  47. '<th class="text-center">Status</th>'+
  48. '<th class="text-center">Data Inclusão</th>'+
  49. '<th class="text-center">Ações</th>'+
  50. '</tr>'+
  51. '</thead>'+
  52. '</tbody>'+
  53. '</table>'+html);
  54.  
  55.  
  56. }
  57. });
  58. }
  59.  
  60.  
  61. public function pegar_aulas() {
  62.  
  63. $usuario = new Usuario();
  64.  
  65. if(isset($_POST['pesquisa']) && !empty($_POST['pesquisa'])) {
  66.  
  67. $value = $_POST['pesquisa'];
  68.  
  69. $usuario->listUsuarioAjax($value);
  70.  
  71. $array = $usuario->listUsuarioAjax($value);
  72.  
  73. echo json_encode($array);
  74.  
  75. exit;
  76.  
  77. } else {
  78. $array = $usuario->listUsuarioAjax("");
  79. print_r($array);
  80. echo json_encode($array);
  81. exit;
  82. }
  83.  
  84. }
  85.  
  86. Resposta navegador:
  87.  
  88. {0: "344", 1: "rodrigues.caio1985@gmail.com", 2: "7363a0d0604902af7b70b271a0b96480",…}
  89. 0
  90. :
  91. "344"
  92. 1
  93. :
  94. "rodrigues.caio1985@gmail.com"
  95. 2
  96. :
  97. "7363a0d0604902af7b70b271a0b96480"
  98. 3
  99. :
  100. "b9b9503dd602b6ebe44aa1d2fbf530b5"
  101. 4
  102. :
  103. "2"
  104. 5
  105. :
  106. "2018-01-26 18:25:27"
  107. 6
  108. :
  109. "2018-01-27 17:53:54"
  110. 7
  111. :
  112. "1"
  113. 8
  114. :
  115. "1516998472.jpg"
  116. dataalteracao
  117. :
  118. "2018-01-27 17:53:54"
  119. datainclusao
  120. :
  121. "2018-01-26 18:25:27"
  122. email
  123. :
  124. "rodrigues.caio1985@gmail.com"
  125. foto
  126. :
  127. "1516998472.jpg"
  128. id
  129. :
  130. "344"
  131. idpessoa
  132. :
  133. "1"
  134. senha
  135. :
  136. "7363a0d0604902af7b70b271a0b96480"
  137. status
  138. :
  139. "2"
  140. token
  141. :
  142. "b9b9503dd602b6ebe44aa1d2fbf530b5"
  143.  
  144.  
  145. Response:
  146.  
  147. {"id":"344","0":"344","email":"rodrigues.caio1985@gmail.com","1":"rodrigues.caio1985@gmail.com","senha":"7363a0d0604902af7b70b271a0b96480","2":"7363a0d0604902af7b70b271a0b96480","token":"b9b9503dd602b6ebe44aa1d2fbf530b5","3":"b9b9503dd602b6ebe44aa1d2fbf530b5","status":"2","4":"2","datainclusao":"2018-01-26 18:25:27","5":"2018-01-26 18:25:27","dataalteracao":"2018-01-27 17:53:54","6":"2018-01-27 17:53:54","idpessoa":"1","7":"1","foto":"1516998472.jpg","8":"1516998472.jpg"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement