Advertisement
Semior001

blablabla

Aug 8th, 2018
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function previewEmployeePhoto(input){
  2.     var input = document.getElementById('employeePhoto');
  3.     if (input.files && input.files[0]) {
  4.         var reader = new FileReader();
  5.         document.getElementById("emplPreview").hidden = false;
  6.         document.getElementById("emplBr1").hidden = false;
  7.         document.getElementById("emplBr2").hidden = false;
  8.         document.getElementById("emplBr3").hidden = false;
  9.         reader.onload = function (e) {
  10.             $('#emplPreview')
  11.                 .attr('src', e.target.result)
  12.                 .width(150)
  13.                 .height(200);
  14.         };
  15.         reader.readAsDataURL(input.files[0]);
  16.     }
  17. }
  18.  
  19. function onRegisterEmployee(form){
  20.     document.getElementById("registerEmployeeMessageContainer").hidden = true;
  21.     var formData = new FormData(form);
  22.     // console.log(form.photo.files[0]);
  23.     formData.append("photo", form.photo.files[0]);
  24.     $.ajax({
  25.         type: "POST",
  26.         url: "scripts/registerEmployee.php",
  27.         data: formData,
  28.         processData: false,
  29.         contentType: false,
  30.         success: function(data){
  31.             document.getElementById("registerEmployeeMessageContainer").hidden = false;
  32.             document.getElementById("registerEmployeeMessage").innerHTML = "<font color='green'>Сотрудник был успешно добавлен в систему</font>";
  33.             console.log(data);
  34.         },
  35.         error: function(err){
  36.             document.getElementById("registerEmployeeMessageContainer").hidden = false;
  37.             document.getElementById("registerEmployeeMessage").innerHTML = "<font color='red'>Возникла ошибка. Подробности в js консоли</font>";
  38.             console.log(data);
  39.         }
  40.     });
  41.    
  42.     return false;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement