I want to create a JavaScript function, which should popup an alert when the user starts typing in the TextBox and the server couldn't retrieve the results in 3 seconds even though it contain the results.
My current code:
function keyup(e) {
if(timeout != null) {
clearTimeout(timeout);
timeout = null;
}
if(jq('.ui-menu-item').is(":visible")) {
time = performaceTiming.responseStart;
timeout = setTimeout(bluff, 3000);
}
else {
timeout = setTimeout(popup, 2000);
}
}
function bluff() {
alert('alert box inside bluff');
}
function popup() {
alert('the requested name could not be found, please search for other name');
}
you don't call the functions named bluff or popup but the undefined variables, you should add () to call the function
if(jq('.ui-menu-item').is(":visible")){
time=performaceTiming.responseStart;
timeout=setTimeout(bluff(),3000);}
else{
timeout=setTimeout(popup(),2000);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.