如果问题标题不够清晰:
我正在使用 jQuery AutoComplete 插件(jQuery UI 1.8.5 的一部分)
我本以为提供的 CSS/图像会包含类似 ajax 的进度图像?
如果没有,创建一个最简单的方法是什么?
这是我的自动完成代码:
$('#query').autocomplete({
source: function (request, response) {
$.ajax({
url: "/Search/FindLocations",
type: "POST",
dataType: "json",
data:
{
searchText: request.term
},
success: function (data) {
response($.map(data, function (item) {
return { name: item.name, value: item.name }
}))
}),
select: function (event, ui) {
// snip... (this is where i display stuff about what they clicked).
}});
上面代码中我应该在哪里隐藏/显示图像?
显然,在“选择”中的代码之后,我可以隐藏图像,但是我可以在哪里“显示”图像?
最佳答案
$('#query').autocomplete({
source: function (request, response) {
//i would show the image here, before starting your ajax request
$("#theImage").show();
$.ajax({
url: "/Search/FindLocations",
type: "POST",
dataType: "json",
data:
{
searchText: request.term
},
success: function (data) {
response($.map(data, function (item) {
return { name: item.name, value: item.name }
}))
}),
select: function (event, ui) {
// snip... (this is where i display stuff about what they clicked).
}});
关于jQuery UI AutoComplete - 如何实现进度指示器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3975291/