如何设置此函数的等待时间。
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");
}
}发布于 2012-04-26 01:32:51
您可以使用setTimeout
setTimeout(function()
{
if($('#MedHistoryGridSec').is(':visible'))
alert('yes');
else
alert('no');
}, 3000);发布于 2012-04-26 01:33:09
您可以将代码包装在回调函数中,并在三秒钟后使用window.setTimeout运行它
var afterThreeSeconds = function() {
if ($("#MedHistoryGridSec").is(":visible")) {
alert("yes we have grid");
}
else{
alert("No Grid");
}
}
window.setTimeout(afterThreeSeconds, 3000);发布于 2012-04-26 01:34:35
您是否可以向药物历史网格函数添加一个参数,该函数包含您希望在该函数成功后执行的代码,然后您可以在药物历史网格函数的末尾调用该函数?
https://stackoverflow.com/questions/10320761
复制相似问题