Question

How can i set wait time for this function.

function UpdateMedicaitonHistory(data) {
     MedicaitonHistoryGrid();
//set a wait time to finish MedicaitonHistoryGrid() like for 3 seconds
// then execute the below code.
if ($("#MedHistoryGridSec").is(":visible")) {
            alert("yes we have grid");
      }
else{
     alert("No Grid");
    }
}
Was it helpful?

Solution

You can use setTimeout:

setTimeout(function()
{
     if($('#MedHistoryGridSec').is(':visible'))
         alert('yes');
     else
         alert('no');
}, 3000);

OTHER TIPS

You could wrap up the code in a callback function and run it after three seconds using window.setTimeout:

var afterThreeSeconds = function() {
  if ($("#MedHistoryGridSec").is(":visible")) {
    alert("yes we have grid");
  }
  else{
    alert("No Grid");
  }
}

window.setTimeout(afterThreeSeconds, 3000);

Can you add a parameter to the medication history grid function taking a function containing the code you want executed after that function succeeds which you can then call at the end of the medication history grid function?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top