English 中文(简体)
jquery ui autocomplete 不干
原标题:jquery ui autocomplete not working exactly

然而,我已经看到了与这一问题有关的所有问题,但无法找到解决办法。 我正在与支离破碎的汽车公司合作。 我的设想是,

I have a check box. When It is checked, an ajax request is sent to server which fetch some information from database and returned the json encode data. On success function I call the jquery autocomplete and in source I provide the data returned by my ajax request. When I start writing some thing in my text box, (I can see in firebug console tab) a get request is sent having all my option which are returned from ajax request like this

 http://localhost/project/module/controller/index/%5B%22Mobile%22,%22Watch%22,%22Lamps%22,%22Harry%20Potter%22,%22Suitcase%22,%22Halloween%22,%22Xmas%22,%22Multiple%22,%22oil%22,%22Empty%20Keywords%22,%22iphone%20theme%22,%22Edit%20theme%22,%22Final%20Theme%22%5D?term=mo

并且没有发生。 没有任何选择可证明汽车完整。 我的法典如下:

<input type="checkbox" name="prebuilt-Themes" id="prebuilt-Themes" onclick="get_all_themes();">

文本框

 <input type="text" id="themes" style="display: none;" class="ui-autocomplete-input">

以及处理麻风病要求的职能

 function get_all_themes()
{

    if($("#prebuilt-Themes").is( :checked ))
    {    
     $( #themes ).show();   
     $.ajax({
            type: POST ,
            //data:({string: abc }),
            url: "<?= $this->baseUrl(); ?>/module/controller/getallthemes",
            success:function(data)
            {
               $(function() {
               $( "#themes" ).autocomplete({
                    source: data

                        });
                });
            }
        });
     }


}

我从我的阿贾克斯请求获得的数据就是如此。

  ["Mobile","Watch","Lamps","Harry Potter","Suitcase","Halloween","Xmas","Multiple","oil","Empty Keywords","iphone theme","Edit theme","Final Theme"]

谁能指导我那天我做错事?

最佳回答

你们需要以json格式,以id、标签和价值等形式做出反应:

[ { "id": "Luscinia svecica", "label": "Bluethroat", "value": "Bluethroat" }, { "id": "Motacilla flava", "label": "Blue-headed Wagtail", "value": "Blue-headed Wagtail" }, { "id": "Cyanistes caeruleus", "label": "Blue Tit", "value": "Blue Tit" }, { "id": "Monticola solitarius", "label": "Blue Rock Thrush", "value": "Blue Rock Thrush" }, { "id": "Anas discors", "label": "Blue-winged Teal", "value": "Blue-winged Teal" }, { "id": "Merops persicus", "label": "Blue-cheeked Bee-eater", "value": "Blue-cheeked Bee-eater" }, { "id": "Tarsiger cyanurus", "label": "Red-flanked Bluetail", "value": "Red-flanked Bluetail" } ]
问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签