$('#profile_sample_form').on('submit', function (event) { event.preventDefault(); $.ajax({ url: "{{ route('profile_picture.store', $employee, false) }}", method: "POST", data: new FormData(this), contentType: false, cache: false, processData: false, dataType: "json", beforeSend: function () { $('#profile_sample_form #action_button').prop('disabled', true); $('#profile_sample_form #action_button').text('{{ trans('file.Adding...') }}'); }, success: function (data) { var html = ''; if (data.errors) { html = '
'; for (var count = 0; count < data.errors.length; count++) { html += '

' + data.errors[count] + '

'; } html += '
'; $('#profile_sample_form .form-control').removeClass('is-invalid'); html += ''; displayErrorMessage(html); } if (data.success) { if (data.profile_picture) { $('#employee_profile_photo').html( ""); $('#employee_profile_photo').append( ""); } $('#profile_sample_form')[0].reset(); displaySuccessMessage(data.success); } $('#profile_sample_form #action_button').text('{{ trans('file.Add') }}'); $('#profile_sample_form #action_button').prop('disabled', false); } }); });