使用 javascript / ajax 设置延迟

发布于 2024-09-07 19:12:59 字数 332 浏览 0 评论 0 原文

结果出现在注释中时,我想延迟

我有一个表单< /代码> > input 用户在 input 中输入他的用户名,然后我使用 AJAX 检查

用户名是否可用。如果是,则注释会显示在输入附近以及

结果

请不要使用 jQuery!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风夜微凉 2024-09-14 19:12:59

您可能需要使用 setTimeout() 来短暂延迟后显示一些内容:

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

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文