如何将加载 gif 动画应用到我的自动建议中?
我很幸运能在美国服务器上拥有我的解决方案,而我的受众位于斯堪的纳维亚半岛(池塘的另一边)。
这使得响应时间有点慢,并且当我使用 AutoComplete 我的搜索框。
为了给用户一些反馈,我想显示一个加载动画 GIF。
问题是我不知道如何在回调之前启动它。 该动画应在 AutoComplete 搜索数据库时启动,并在数据库搜索完成时停止。
我的 javascript 看起来像这样:
jQuery(document).ready(function() {
var options = autosuggestOptions();
var response = new bsn.AutoSuggest('mySearchBox', options);
});
function autosuggestOptions()
{
var options = {
script:"wp-content/themes/test/include/someFile.php?",
varname:"input", minchars: 2, delay: 200, json:true, maxresults:15, timeout: 5000,
callback: function (obj) { (.. do stuff here ..) }
};
return options;
}
我的动画 gif 位于 内。
有人建议吗?
I'm so lucky to have my solution on an US server, while my audience is located in Scandinavia (on the other side of the pond).
This makes the respons time a bit slow, and not ideal when I'm using AutoComplete for my search box.
To give the user some feedback, I want to display a animated loading GIF.
The problem is that I don't know how to initiate it before callback.
The aniamtion should start when AutoComplete searches the DB, and stop when DB search is finished.
My javascript looks something like this:
jQuery(document).ready(function() {
var options = autosuggestOptions();
var response = new bsn.AutoSuggest('mySearchBox', options);
});
function autosuggestOptions()
{
var options = {
script:"wp-content/themes/test/include/someFile.php?",
varname:"input", minchars: 2, delay: 200, json:true, maxresults:15, timeout: 5000,
callback: function (obj) { (.. do stuff here ..) }
};
return options;
}
My animated gif is inside <div class="loader"></div>
.
Suggestions anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
立即在
autosuggestOptions()
中显示 div。然后将其隐藏在回调中。Immediately within
autosuggestOptions()
, show the div. Then hide it within the callback.