简体   繁体   English

为什么jQuery的Ajax AutoComplete无法正常工作?

[英]why Ajax AutoComplete for jQuery not working?

hi a im using codeigniter and Ajax AutoComplete for jQuery 嗨,即时通讯使用codeigniter和Ajax AutoComplete for jQuery

in my jquery i define my auto complete like this 在我的jQuery中,我这样定义我的自动完成

    a = $('.city').autocomplete({
        serviceUrl: "<? echo $this->config->item('base_url'); ?>home/auth/city_autocomplete",
    });

.city is the class name of my input field .city是我输入字段的类名

my action city_autocomplete is this 我的动作city_autocomplete是这个

    function city_autocomplete(){

        $array = array('query'=>'Li','suggestions' => array('Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania'));                       
        echo  json_encode($array) ;
    }

i have hard corded values here 我在这里有严格的价值观

my json_encoded array is this 我的json_encoded数组是这个

{"query":"Li","suggestions":["Liberia","Libyan Arab Jamahiriya","Liechtenstein","Lithuania"]}

when i enter a letter in city input box , i can see the above response json array , but the problem is no suggesion vlues is displayed . 当我在城市输入框中输入字母时,可以看到上面的响应json数组,但问题是没有显示建议线索。 when i check 当我检查

<div id="AutocompleteContainter_c6592" style="position: absolute; z-index: 9999; top: 590.85px; left: 533.383px;">

there is no options 没有选择

why is this happening , i have done this before exactly the same way and it worked perfectly , why the suggessons not showing . 为什么会这样,我以前完全一样地做到了,而且效果很好,为什么提示没显示。 please help me ............... :( 请帮我 ............... :(

UPDATE 更新

this is the library i am using 这是我正在使用的图书馆

http://www.devbridge.com/projects/autocomplete/jquery/ http://www.devbridge.com/projects/autocomplete/jquery/

I think you don't allow query parameters in config.php of CI allow the query parameters 我认为您在CI的config.php中不允许查询参数允许查询参数

$config['enable_query_strings'] = TRUE;

OR user ajax post method OR用户ajax发布方法

or replace the line in jquery.autocomplete.js 或替换jquery.autocomplete.js中的行

$.get(this.serviceUrl, me.options.params, function(txt) { me.processResponse(txt); }, 'text');

to

$.post(this.serviceUrl, me.options.params, function(txt) { me.processResponse(txt); }, 'text');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM