Welcome Guest, Not a member yet? Register   Sign In
Short look why, please: JQuery UI autocomplete from database
#1

[eluser]Jan_1[/eluser]
Sorry, I don't get it. Could somebody please have a look and give me a hint? Thank you!!!

I have tryed a lot of variations and had a good look in the dokumentation, but nothing has worked. It's a fresh Codeigniter and "?" is permitted as uri_chars in config/config.

Code:
<s.c.r.i.p.t>
$(function()
    {   var availableTags = [
   "ActionScript",
   "AppleScript",
   "C++",
   "Clojure",
  ];
  $( "#tags" ).autocomplete({
   source: availableTags
  });
    });  
</s.c.r.i.p.t>
&lt;input name="group" id="tags"/&gt;
works fine!

but not this one:
View:
Code:
<s.c.r.i.p.t>
$(function()
    {   $( "#groups" ).autocomplete({
source: "index.php/accounting/booking_set_ajax_groups/",
            method: "POST",
minLength: 0,
select: function( event, ui )
                {
  log( ui.item ?
   "Selected: " + ui.item.value + " aka " + ui.item.id :
   "Nothing selected, input was " + this.value );
  }
  });
    });  
</s.c.r.i.p.t>
&lt;input name="group" id="groups"/&gt;
Controller:
Code:
function ajax_groups()
    {
        $keyword = $this->input->post('term');
        $this->db->SELECT('group')->LIKE('group', $keyword)->distinct();
        $query  = $this->db->get('database_groups');
        if($query->num_rows() >0)
        {   $i = 0;
            foreach($query->result() as $row)
            {
            $data[] = array('id' => $i, 'label' => 'group', 'value'=> $row->group);
            $i++;
            }
        }
        echo json_encode($data);        
    }

If I ask the Browser for my Controller, I get these groups names like

[{"id":0,"label":"group","value":"group1"},{"id":1,"label":"group","value":"group2"},{"id":2,"label":"group","value":"group3"}]

When I do type a 'space' I get an erroer-message in console:

GET http://url.tld/index.php/controller/ajax_groups?term=Pr+ 404 (Not Found)
f.support.ajax.f.ajaxTransport.sendjquery.min.js:4
f.extend.ajaxjquery.min.js:4
a.widget._initSource.a.isArray.options.source.string.sourcejquery-ui.min.js:12
a.widget._searchjquery-ui.min.js:12
a.widget.searchjquery-ui.min.js:12
(anonymous function)



Messages In This Thread
Short look why, please: JQuery UI autocomplete from database - by El Forum - 01-28-2012, 07:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB