开发者

Set delay with javascript / ajax

开发者 https://www.devze.com 2023-01-06 03:44 出处:网络
I want to make a delay when the result comes in the note. I have 开发者_如何学编程a form > input the user types his username in the input and I check with AJAX

I want to make a delay when the result comes in the note.

I have 开发者_如何学编程a form > input the user types his username in the input and I check with AJAX

if the username is available or not. If yes a note shows up near the input with the

result.

Please no jQuery!


You may want to use setTimeout() to display something after a short delay:

var delay = 1000;            // 1 second
var result = 'note here';    // the result from your AJAX response

setTimeout(function() { 
   document.getElementById('note').innerHTML = result; 
}, delay);
0

精彩评论

暂无评论...
验证码 换一张
取 消