Call an Ajax Function after ProgressBar End

Viewed 28

I have below ajax which I am calling currenlty on form submit. Based on the return result I am showing an alert message only. What I need to do - show a progressbar for some seconds on body load and at the end of the timer call below ajax and based on the return results hide the progressbar and show a success/error msg. How to do this

<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>

<script type="text/javascript">
$(document).ready(function() {
$('#loginform').submit(function(e) {
    e.preventDefault();
    $.ajax({
        type: "POST",
        url: 'subscribe.php',
        data: $(this).serialize(),
        success: function(response)
        {
            var jsonData = JSON.parse(response);

            // user is logged in successfully in the back-end
            // let's redirect
            if (jsonData.success == "1")
            {
                alert('You Successfully Subscribed to this Topic!');
                                }
            else
            {
                alert('Unsubscribed From This Topic Successfully!');
                
            }
       }
   });
 });
 });
 </script>
0 Answers
Related