Advertisement
Guest User

Untitled

a guest
Jan 11th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.35 KB | None | 0 0
  1. $('#tastingInputModal').on('submit', function (e) {
  2.     e.preventDefault();
  3.     var turn_id = $('#tasting-date-select').val();
  4.     var token = $('#token').val();
  5.     var url = '/saveTasting';
  6.     var comment = $('#tasting-comment').val();
  7.     var tasting = $(" input[type='radio']:checked").val();
  8.  
  9.     var date = $('#tasting-date-select').find(':selected').data('date');
  10.  
  11.     $('#tasting-comment').empty();
  12.  
  13.     $.ajax({
  14.         url: url,
  15.         method: 'POST',
  16.         data: {
  17.             _token: token,
  18.             turn: turn_id,
  19.             tasting: tasting,
  20.             comment: comment,
  21.             date: date
  22.         },
  23.         success: function (data) {
  24.             $('#degustacion').modal('hide');
  25.         },
  26.         error: function (data) {
  27.             if (data.status === 422) {
  28.                 for (var item in data.responseJSON) {
  29.                     if (data.responseJSON.hasOwnProperty(item)) {
  30.                         data.responseJSON[item].forEach(function (t) {
  31.                             var li = document.createElement('li');
  32.                             li.appendChild(document.createTextNode(t));
  33.                             $('#tastingInputErrorList').append(li);
  34.                         })
  35.                     }
  36.                 }
  37.                 $('#tastingInputErrorList').show()
  38.             }
  39.         }
  40.     });
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement