Jquery自动完成最小长度问题 [英] Jquery autocomplete minlength problem

查看:94
本文介绍了Jquery自动完成最小长度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquey autocomplete进行自我提示。我使用min_length:3因为我想要当用户键入3个字符然后它显示sugestion.But它无法正常工作。有时它在输入1个字符后显示建议。我给出了代码:







i use jquey autocomplete for autosuggestion.I use min_length:3 because i want that when user type 3 characters then it show the sugestion.But it is not working properly.Sometimes it show suggestion after typing 1 character.My code is given:



$("#state").autocomplete({
//		var str : $("#state").val(),
		source: function(request, response) {
            $.ajax({
                url: "autocomp3.asp",
                dataType: "json",
                data: {
                    term : request.term,
                    tbl_name : "UserAccounts",
					ID : "accID",
					Value : "accFirstName"
					//country_id : $("#country_id").val()
                },
                success: function(data) {
                    response(data);
                }
            });
        },
        min_length: 3,
        delay: 300
    });







需要帮助。



我尝试过:



$(函数(){

< br $>






$(#state)。autocomplete({

// var str:$(#state)。val(),

source:function(request,response){

$ .ajax({

url:autocomp3.asp,

dataType:json,

数据:{

term:request。期限,

tbl_name:UserAccounts,

ID:accID,

价值:accFirstName

// country_id:$(#country_id)。val()

},

成功:函数(数据){

响应(数据);
}

});

},

min_length:3,

延迟:300

});





});




Help is needed.

What I have tried:

$(function() {




$("#state").autocomplete({
// var str : $("#state").val(),
source: function(request, response) {
$.ajax({
url: "autocomp3.asp",
dataType: "json",
data: {
term : request.term,
tbl_name : "UserAccounts",
ID : "accID",
Value : "accFirstName"
//country_id : $("#country_id").val()
},
success: function(data) {
response(data);
}
});
},
min_length: 3,
delay: 300
});


});

推荐答案

#state)。autocomplete({
< span class =code-comment> // var str:
("#state").autocomplete({ // var str :


(#state)。val(),
来源: function (请求,响应){
("#state").val(), source: function(request, response) {


.ajax({
url: autocomp3.asp
dataType: json
data:{
term:request.term,
tbl_name: UserAccounts
ID: accID
值: accFirstName
// country_id:
.ajax({ url: "autocomp3.asp", dataType: "json", data: { term : request.term, tbl_name : "UserAccounts", ID : "accID", Value : "accFirstName" //country_id :


这篇关于Jquery自动完成最小长度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆