Guest User

Untitled

a guest
Oct 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. function ajaxExportar(colaboradores) {
  2. var token = $("#token").val();
  3. var json = stringToJson(colaboradores);
  4. $.ajax({
  5. url: '/colaborador/exportar',
  6. type: 'POST',
  7. method: 'POST',
  8. dataType: 'json',
  9. ContentType: 'application/json; charset=utf-8',
  10. headers: {'X-CSRF-TOKEN': token},
  11. data: {'json': json, '_token': token},
  12. beforeSend: function () {
  13. $('a').addClass('disabled');
  14. $("#overlay").faLoading({
  15. "type": "add",
  16. "icon": "fa-refresh",
  17. "status": 'loading',
  18. "text": false,
  19. "title": ""
  20. });
  21. },
  22. success: function (response) {
  23. console.log(response);
  24. var json = (response);
  25. $("#overlay").faLoading("remove");
  26. $('a').removeClass('disabled');
  27. if (json.error) {
  28. new PNotify({
  29. title: 'Erro!',
  30. text: json.error,
  31. icon: 'fa fa-warning',
  32. type: 'error',
  33. styling: 'fontawesome'
  34. });
  35. }
  36. },
  37. statusCode: {
  38. //erro de autenticação em caso de logout
  39. 401: function () {
  40. alert("Necessário fazer login novamente!");
  41. window.location = "/home";
  42.  
  43. $colaborador=json_encode($json);
  44.  
  45.  
  46. print_r($colaborador);
  47. die();
  48. }
  49.  
  50. Route::post('colaborador/exportar', 'CadastroColaboradorController@exportar');
Add Comment
Please, Sign In to add comment