Q: How to refresh another ajax function after the success of a different one I made a script that shows participants as a table from my database using AJAX, and I used another AJAX to assign privilege for them, it went all good, but I need a way to refresh the table after giving someone privileges.
I tried
      load_data(page, query);

in the success function of the second ajax but it didn't work, can someone give me a way to refresh the table from the first AJAX without refreshing the whole page?
  $(document).ready(function(){
     
     var query = $('#query').val();

    load_data(1);

    function load_data(page, query = '')
    {
      $.ajax({
        url:"fetchact.php",
        method:"POST",
        data:{page:page, query:query},
        beforeSend: function() {
        document.getElementById("loader").style.display = "block";
           },
        success:function(data)
        {
        document.getElementById("loader").style.display = "none";
          $('#table').html(data);
        }
      });
    }

    $(document).on('click', '.page-link', function(){
      var page = $(this).data('page_number');
     var query = $('#query').val();

      load_data(page, query);
    });

 

    $("#query").on('change', function() {
         var query = $('#query').val();
          load_data(1, query);
        });
    
    $(document).on("click", "#rlbtn", function(){
       var id = $(this).data('id');
       var serial = $(this).data('serial');
       var role = $(this).val();
       Swal.fire({
  title: 'Confirmation',
  text: "Are you sure you want to assign "+ id +" as a "+ role +"?",
  icon: 'warning',
  showCancelButton: true,
  confirmButtonColor: '#3085d6',
  cancelButtonColor: '#d33',
  confirmButtonText: 'Yes'
}).then((result) => {
  if (result.isConfirmed) {
  $.ajax({
        url:"changerole.php",
        method:"POST",
        data:{id:id, serial:serial, role:role},
        beforeSend: function() {
        document.getElementById("loader").style.display = "block";
           },
        success:function(data)
        {
            
            if(data == 1){
                document.getElementById("loader").style.display = "none";
      
                Swal.fire(
  'Thank you!',
  'You successfully assigned '+ id +' as a '+ role +'!',
  'success'
)
      load_data(page, query);
            } else {
                Swal.fire(
  'Assign failed!',
  'An unknown error has occured, please try later!',
  'error'
)
            }
        

        }
      });
  }
})



      
      

        });
        
        
  });

That's my code, someone help...

A: You can recall the function like this:


$(document).ready(function(){

  function functionName(){
      //function code
  }
  
  function anotherFunctionName(){
      //function code
      
      if (condtion) {
          functionName();
      }
  }

});


