删除自动完成错误的微调器/加载图像
如果自动完成出现错误/失败情况,您能否帮助我了解如何删除旋转器/加载图像?
如果我收到错误“由于意外错误,我们无法加载数据”,我会看到正在加载的图像,并且我想删除该图像。
下面是片段
$("Autotxt").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Webservice.asmx/GetNames",
data: "{'prefixText':'" + request.term + "'}",
dataType: "json",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('|')[0],
val: item.split('|')[1]
}
}))
},
error: function (result) {
alert("Due to unexpected errors we were unable to load data");
ServiceFailed(result);
},
failure: function (response) {
alert("Due to unexpected errors we were unable to load data");
}
});
},
select: function (event, ui) {
txtSoID(ui.item.val);
},
minLength: 4
});
function txtID(val)
{
alert(val)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您指的是通过 ui 提供的加载类,您应该能够执行以下操作:
我在 jqueryUI 开发站点位于页面底部,他们在那里讨论 css 和主题。
If you are referring to the loading class available through the ui, you should be able to do the following:
I found the class information on the jqueryUI development site at the bottom of the page where they talk about css and themes.
我在您的代码中没有看到任何加载屏幕。但是您可以简单地添加该函数
并在失败或错误回调中调用它,例如
I dont see any loading screen in your code. But you could simply add the function
and call it in your failure or error callback like
对这些图像执行检查元素,检查它们的类(例如“loader”),然后将其放入错误和失败回调
$(".loader").hide()
中。Do an inspect element on those images, check their class ('loader' for example) and then do put this in your error and failure callback
$(".loader").hide()
.改编自我在这里的答案,添加以下代码以在搜索完成后执行(即使有 0 个结果):
该代码将触发一个事件 (autocompletesearchcomplete),然后您可以绑定到:
希望这有帮助...
Adapted from my answer here, add the following code to execute after a search is complete (even with 0 results):
That code will trigger an event (autocompletesearchcomplete) that you can then bind to:
Hope this help...