Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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 autocomplete调用select中的另一个webmethod_Jquery_Autocomplete - Fatal编程技术网

使用jQuery autocomplete调用select中的另一个webmethod

使用jQuery autocomplete调用select中的另一个webmethod,jquery,autocomplete,Jquery,Autocomplete,在我的应用程序中,我使用jQuery autocomplete来填充一个文本框和一个带有id的隐藏字段。它工作正常 现在,我想根据所选id提取更多数据。我是jQuery新手,无法找到基于此的任何其他线程。下面是我用于从列表中选择项目的代码 select: function (event, ui) { this.value = ui.item.value;

在我的应用程序中,我使用jQuery autocomplete来填充一个文本框和一个带有id的隐藏字段。它工作正常

现在,我想根据所选id提取更多数据。我是jQuery新手,无法找到基于此的任何其他线程。下面是我用于从列表中选择项目的代码

                    select: function (event, ui) 
                {
                    this.value = ui.item.value;
                    $("#" + name).val(ui.item.label);
                    $("#" + idfld).val(ui.item.value);
                    return false;
                }

在这个函数中,我想调用另一个web方法,它将返回与id相对应的数据。我想根据这些数据填充其他文本框。

我是通过在同一字段中获取更多值来实现的。这是密码

.autocomplete(
            {
                source: function (request, response) {
                    $.ajax(
                    {
                        contentType: "application/json; charset=utf-8",
                        url: "../svc/SearchService.svc/GetMatchingVehiclesInfo",
                        data: "VehicleSearchName=" + $("#" + name).val(),
                        type: "GET",
                        dataType: "json",
                        success: function (data) {
                            response($.map(data.GetMatchingVehiclesInfoResult, function (value, key) {
                                return {
                                    label: value.Name, //vehicle name
                                    //below i combined multiple values into same field
                                    value: value.ID + '#' + value.BodyType + '#' + value.FuelType + '#' + value.Seats
                                };
                            }));
                        },
                        error: function (result) {
                            alert("Error");
                        }
                    });
                },
                search: function () {
                    // custom minLength
                    var term = extractLast(this.value);
                    if (term.length < 1) {
                        return false;
                    }
                },
                focus: function () {
                    // prevent value inserted on focus
                    return false;
                },
                select: function (event, ui) {
                    this.value = ui.item.value;
                    $("#" + name).val(ui.item.label);
                    //here i extracted the value using split       
                    $("#<%=hdnVehicle.ClientID%>").val(ui.item.value.split('#')[0]);
                    $("#<%=ddlFueltype.ClientID%>").value = ui.item.value.split('#')[2];
                    return false;
                }
但即使我得到了这个值,DropDownListDDLFoureType值也不会改变。我正在努力想办法。

看看: