Cakephp 2.1和Jquery UI自动完成不工作

Cakephp 2.1和Jquery UI自动完成不工作,jquery,cakephp,user-interface,autocomplete,Jquery,Cakephp,User Interface,Autocomplete,我尝试在cakephp 2.1中实现自动完成从数据表中获取的数据没有成功,请帮助我 默认布局中的 echo $this->Html->script('jquery-1.8.3'); echo $this->Html->script('jquery-ui-1.9.2.custom'); 在视图文件中 $('.TextBox').keydown(function (e){ var FieldId = $(this).attr('id'); v

我尝试在cakephp 2.1中实现自动完成从数据表中获取的数据没有成功,请帮助我

默认布局中的

    echo $this->Html->script('jquery-1.8.3');
    echo $this->Html->script('jquery-ui-1.9.2.custom');
在视图文件中

 $('.TextBox').keydown(function (e){
   var FieldId =  $(this).attr('id');
   var ColName =  $(this).attr('title');
   var table = document.getElementById("dbTable").value;
   var TableName = table + "_docs";
   var TextValue = ""

   if (e.which >= 32 || e.which < 127) {
      var c = String.fromCharCode(e.which);
      TextValue = $(this).val() + c;
      }

  if(TextValue != ""){
              $.ajax({
              type:'POST',
              url:"../AutoSearch/" + TableName + "/" + ColName + "/" + TextValue ,
              success:function(response){
              var data = response.split("|");
              $('#' + FieldId).autocomplete(data);
              }
        });
       }
  });
在型号中

     public function getAutoComplete($table,$col,$text){
          $sql = "select " . $col . " from " . $table . " where " . $col . " Like '%" . $text . "%'";
          $ret = $this->query($sql);
          $rText = "";
          foreach($ret as $val){
               if($rText == ""){
                     $rText = $val[$table][$col] . "|";}
                  else {
                $rText = $rText . $val[$table][$col] . "|";}
            }
              return $rText;
    }
firebug中的错误消息

TypeError:this.source不是函数


.应用(实例、参数)

作为起点,我建议使用默认jQuery autocomplete并查看类似的内容

在视图中

$('.TextBox').autocomplete({
        source: function(request, response) {
            $.ajax({
               type:'POST',
               url:"/your_controller/your_action/",
               data: {
                    column: 'col',
                    search: request.term // request.term will have value in field
                },
               success:function(response){
                    // to see what you are getting to browser
                    // console.log(response);
                    response( $.map( response, function( item ) {
                        // depending on what you send, return object you need
                        // label will be shown in list, value will be set when selected
                        return {
                            label: item.name,
                            value: item.id
                        }
                    }));
                 }
               }
            });
        }
    });
内部控制器

public function your_action() {
    // to see what you are getting to controller
    // debug($this->request->data);
    exit( json_encode($this->YourModel->find('list', array('conditions' => array())));
}

这样做会使应用程序易受攻击。您可以从用户输入中提供自定义的查询参数。我经常使用不同的表,从控制器和模型响应可以在firebug中看到,但没有下拉列表。我对cakephp和jquery不熟悉,但我已完成dms所有其他工作正常我需要自动完成破冰器上的清晰连接请
public function your_action() {
    // to see what you are getting to controller
    // debug($this->request->data);
    exit( json_encode($this->YourModel->find('list', array('conditions' => array())));
}