0

I have this for a success function:

success: function(data){
        $('#pleaseWaitDialog').modal('hide');
          data = $.trim(data);
          if(data == 'true'){
            $('#myTab a[href="#intro"]').tab('show');
          }
          else{
            $("#alert").attr('class', 'alert alert-warning');
            $("#alert").html('Your Pass Phrase was incorrect! Please try again.');
          }
      }

How do I delay the $('#pleaseWaitDialog').modal('hide'); from happening for 1200 milliseconds.

I've tried:

$('#pleaseWaitDialog').modal('hide').delay(1200);

But it did nothing.

user3367639
  • 597
  • 3
  • 6
  • 20

6 Answers6

0

Please use setTimeout() to delay in JavaScript.

RKS
  • 1,370
  • 11
  • 20
0

You can use the javascript setTimeout function. Like so..

setTimeout(function(){
    $('#pleaseWaitDialog').modal('hide')
},
1200);

This will do what you're asking. See here for more information.

Bryan
  • 3,449
  • 1
  • 19
  • 23
0

use setTimeout like this:

setTimeout(function(){
    $('#pleaseWaitDialog').modal('hide')
},
1200);
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
pj013
  • 1,393
  • 1
  • 10
  • 28
0

put you code inside

setTimeout(function(){
      $('#pleaseWaitDialog').modal('hide');
  },1200);
Maneesh Singh
  • 555
  • 2
  • 12
0

You have to call .delay before calling .modal. See the example on jQuery API documentation page.

BrunoLM
  • 97,872
  • 84
  • 296
  • 452
0

you can use

setTimeout() function with parameters function you wanna call and time of delay in milliseconds.

like

 var timeout = setTimeout(function(){
      //codes here.
  },1200);

and

use clearTimeout(timeout); to stop the timeout.

kenicky
  • 431
  • 4
  • 14