Advertisement
Guest User

wywołaj xhr

a guest
Jan 15th, 2022
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. function NowaNotyfikacja() {
  2.  
  3. if($('#notyfikacjaTytul').val() != '' && $('#notyfikacjaTresc').val() != '' && $('#notyfikacjaUzytkownicy').val() != '') {
  4.  
  5. var UserzyListaSelect = document.getElementById('notyfikacjaUzytkownicy');
  6. var DlaKogoNotyfikacja = UserzyListaSelect.options[UserzyListaSelect.selectedIndex].value;
  7.  
  8. const NowaNotyfikacja = {
  9. notyfikacjaTytul: $('#notyfikacjaTytul').val(),
  10. notyfikacjaTresc: $('#notyfikacjaTresc').val(),
  11. notyfikacjaDlaKogo: DlaKogoNotyfikacja
  12. };
  13.  
  14. const jsonString = JSON.stringify(NowaNotyfikacja);
  15. const xhr = new XMLHttpRequest();
  16.  
  17. xhr.open("POST", "../../php-scripts/dodaj-notyfikacje.php");
  18. xhr.setRequestHeader("Content-Type", "application/json");
  19. xhr.send(jsonString);
  20.  
  21. $('#notyfikacjaTytul').trigger("reset");
  22.  
  23. $('#toast-tytul').html('Sukces');
  24. $('#toast-message').html('Wykonano operację');
  25.  
  26. $('.toast').toast('show');
  27.  
  28. }
  29. else
  30. {
  31. alert("Wypełnij formularz");
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement