gpt4 book ai didi

javascript - 仅当用户在 jquery UI 自动完成中暂停时才触发 ajax 请求

转载 作者:行者123 更新时间:2023-11-29 17:22:25 25 4
gpt4 key购买 nike

我有一个 jQuery UI 自动完成表单,它从远程源获取数据,但当连接速度慢时,它会变得不稳定(请求排队,并弄乱结果)。我们如何在用户暂停之前阻止请求触发。

最佳答案

我认为 delay 选项应该适合你:

The delay in milliseconds the Autocomplete waits after a keystroke to activate itself. A zero-delay makes sense for local data (more responsive), but can produce a lot of load for remote data, while being less responsive.

默认情况下,它是 300(毫秒),但您应该增加它以满足您的需要。

$("#my-input").autocomplete({
/* options */,
delay: 750
});

例如比较下面两个例子:

关于javascript - 仅当用户在 jquery UI 自动完成中暂停时才触发 ajax 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11733706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com