I've run into this problem where my ajax request processes too fast to show my loading icon, I'd just like it to run through for a second or so, how would I be able to achieve this?
HTML:
<img class="loader" id="loader" src="Social_Icons/loader.svg" alt="Book Loader Icon">
JS:
$(document).on('click','#sub',function(e) {
    function showLoading(){
        document.getElementById("loader").style = "visibility: visible";
    };
        function hideLoading(){
        document.getElementById("loader").style = "visibility: hidden";
    }
        showLoading();
      var data = $("#text").serialize();
      $.ajax({
             data: data,
             type: "post",
             url: "processing.php",
             success: function()
             {
                 hideLoading();
                 alert("success");
             },
             error: function()
              {
                  hideLoading();
                  alert("save failed");
              }
            });
     });
CSS:
.loader {
position: fixed;
right: 2%;
bottom: 0%;
width: 15vmin;
visibility: hidden;
}
Any help would be fantastic! :)