Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function loadPage() {
  2.         $.ajax({
  3.             type: "GET",
  4.             url: "classes/ajax/pagesLoad.php",
  5.             dataType: "html",            
  6.             success: function(response) {
  7.                 $("#pagesload").html(response);
  8.             }
  9.         });        
  10.     }
  11.     $(document).ready(function() {
  12.         loadPage();
  13.     });
  14.     $("#addwebsites").submit(function() {
  15.         event.preventDefault();
  16.         $.ajax({
  17.             url: "classes/ajax/addPage.php",
  18.             type: "POST",
  19.             data: new FormData(this),
  20.             contentType: false,
  21.             cache: false,
  22.             processData: false,
  23.             success: function(response){
  24.                 if(!response){
  25.                     document.getElementById('name').value = "";
  26.                     document.getElementById('url').value = "";
  27.                     Swal.fire(
  28.                       'Sikeres mentés.',
  29.                       '',
  30.                       'success'
  31.                     )
  32.                     loadPage();
  33.                 } else {
  34.                     Swal.fire(
  35.                       'Sikertelen mentés.',
  36.                       response,
  37.                       'error'
  38.                     )
  39.                 }          
  40.             }
  41.         });
  42.     });
  43.     function deleteText(id) {
  44.         Swal.fire({
  45.             title: 'Biztos vagy benne?',
  46.             text: "A szöveg törlése végleges és visszavonhatatlan.",
  47.             icon: 'warning',
  48.             showCancelButton: true,
  49.             confirmButtonColor: '#3085d6',
  50.             cancelButtonColor: '#d33',
  51.             confirmButtonText: 'Törlés',
  52.             cancelButtonText: 'Mégsem'
  53.         }).then((result) => {
  54.             if (result.value) {
  55.                 $.ajax({
  56.                     url: "classes/ajax/deleteText.php",
  57.                     type: "POST",
  58.                     data: {
  59.                         'id': id
  60.                     },
  61.                     success: function(response) {
  62.                         $('#' + id).fadeOut();
  63.                     }
  64.                 });
  65.                 Swal.fire(
  66.                     'Törölve',
  67.                     '',
  68.                     'success'
  69.                 )
  70.             }
  71.         })
  72.  
  73.     }
  74.     function deleteWebsite(id) {
  75.         Swal.fire({
  76.             title: 'Biztos vagy benne?',
  77.             text: "A weboldal törlése végleges és visszavonhatatlan.",
  78.             icon: 'warning',
  79.             showCancelButton: true,
  80.             confirmButtonColor: '#3085d6',
  81.             cancelButtonColor: '#d33',
  82.             confirmButtonText: 'Törlés',
  83.             cancelButtonText: 'Mégsem'
  84.         }).then((result) => {
  85.             if (result.value) {
  86.                 $.ajax({
  87.                     url: "classes/ajax/deleteWebsite.php",
  88.                     type: "POST",
  89.                     data: {
  90.                         'id': id
  91.                     },
  92.                     success: function(response) {
  93.                         loadPage();
  94.                     }
  95.                 });
  96.                 Swal.fire(
  97.                     'Törölve',
  98.                     '',
  99.                     'success'
  100.                 )
  101.             }
  102.         })
  103.  
  104.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement