Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui 删除自动完成中出现错误的微调器/加载图像_Jquery Ui_Jquery_Autocomplete - Fatal编程技术网

Jquery ui 删除自动完成中出现错误的微调器/加载图像

Jquery ui 删除自动完成中出现错误的微调器/加载图像,jquery-ui,jquery,autocomplete,Jquery Ui,Jquery,Autocomplete,如果错误/失败的情况下自动完成,您可以帮助我删除微调器/加载图像吗 如果我收到错误“由于意外错误,我们无法加载数据”,我会看到正在加载的图像,并希望删除该图像 下面是片段 $("Autotxt").autocomplete({ source: function (request, response) { $.ajax({ type: "POST", contentType: "application/json; char

如果错误/失败的情况下自动完成,您可以帮助我删除微调器/加载图像吗

如果我收到错误“由于意外错误,我们无法加载数据”,我会看到正在加载的图像,并希望删除该图像

下面是片段

  $("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)
}

我在你的代码中没有看到任何加载屏幕。但是您可以简单地添加函数

var removeSpinner = function() {
    $("yourloader").hide();
}
并在失败或错误回调中调用它,如

   error: function (result) {
        removeSpinner();
        alert("Due to unexpected errors we were unable to load data");
        ServiceFailed(result);
    }

我在你的代码中没有看到任何加载屏幕。但是您可以简单地添加函数

var removeSpinner = function() {
    $("yourloader").hide();
}
并在失败或错误回调中调用它,如

   error: function (result) {
        removeSpinner();
        alert("Due to unexpected errors we were unable to load data");
        ServiceFailed(result);
    }

如果您指的是通过ui提供的加载类,则应该能够执行以下操作:

 error: function (result) {
     $('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
     // or .hide()
     alert("Due to unexpected errors we were unable to load data");
     ServiceFailed(result);
 },

我在页面底部找到了关于css和主题的类信息

如果您指的是通过ui提供的加载类,您应该能够执行以下操作:

 error: function (result) {
     $('.ui-autocomplete-loading').removeClass("ui-autocomplete-loading");
     // or .hide()
     alert("Due to unexpected errors we were unable to load data");
     ServiceFailed(result);
 },

我在页面底部找到了关于css和主题的类信息

在这些图像上执行inspect元素,检查它们的类('loader'),然后将其放入错误和故障回调
$(“.loader”).hide()

在这些图像上执行inspect元素,检查它们的类('loader'),然后将其放入错误和故障回调
$(.loader”).hide()

根据我的回答,添加以下代码以在搜索完成后执行(即使搜索结果为0):

该代码将触发一个事件(autocompletesearchcomplete),然后您可以绑定到该事件:

$("#q").bind("autocompletesearchcomplete", function(event, contents) {
    /* Remove spinner here */
});

希望有此帮助…

根据我的回答改编,添加以下代码以在搜索完成后执行(即使搜索结果为0):

该代码将触发一个事件(autocompletesearchcomplete),然后您可以绑定到该事件:

$("#q").bind("autocompletesearchcomplete", function(event, contents) {
    /* Remove spinner here */
});

希望此帮助…

图像的html是什么?图像的html是什么?这将删除dom节点并防止再次调用它。这将删除dom节点并防止再次调用它。