0

I have created modal pop up to upload document. If its successfully upload then I added $("#success-alert") for display meassage but modalpop close immediately

I want the user can easily read message.

var Urldata = "../controllerName/functionname";
$.ajax({
    type: "POST",
    url: Urldata,
    data: fd,
    dataType: "json",
    cache: false,
    processData: false,
    contentType: false,
    success: function (response) {

        //for display message on DocsModal
        $("#success-alert").fadeTo(2000, 500).slideUp(500, function () {
            $("#success-alert").slideUp(500);
        });

        //I want wait for 10 sec for read meassage

        //this will close DocsModal
        $('#DocsModal .close').trigger('click');
        $("#DocsModal").modal('hide');


    }
});
raj
  • 13
  • 6
  • Possible duplicate of [How to await the ajax request?](https://stackoverflow.com/questions/27612372/how-to-await-the-ajax-request) – samtrion Dec 04 '18 at 06:26

1 Answers1

0

You can use window.setTimeout() function to wait for 10 seconds before hiding the modal, see this example below:

// number in milliseconds, 10 seconds mean 10000
window.setTimeout(function() {
    $('#DocsModal .close').trigger('click');
    $("#DocsModal").modal('hide');
}, 10000);

Reference: window.setTimeout() function

Tetsuya Yamamoto
  • 24,297
  • 8
  • 39
  • 61