0

我正在使用 jquery tagit api,我已经编写了我的代码

  $(document).ready(function() {
  $("#mytags").tagit({
    tagSource: function(search, showChoices) {
      $.ajax({
        url: "http://localhost/UI/user/taggin.php",
        data: {search: search.term},
        success: function(choices) {
          showChoices(choices);
        }
      });
    }
  });
  });

这是我的html

            <tr>                        
                    <td>Tags</td>
                        <td><input id="mytags"  class= "ulc" name = "mytags"></ul>
                    </td>

                </tr>   

http://localhost/UI/user/taggin.php正在返回数据,例如

["tag1","tag2","surgeon"]

json格式

请告诉我我做错了什么,所以我的自动完成在这里不起作用

4

2 回答 2

0

Jquery UI's autocomplete is another option.

于 2012-08-30T19:31:24.820 回答
0

尝试这个

tagSource: function(search, showChoices) {
    var that = this;
    $.ajax({
        url: "/tags/autocomplete.json",
        data: {
            q: search.term
        },
        success: function(choices) {
            showChoices(that._subtractArray(choices, that.assignedTags()));
        }
    });
}​

看看这个github问题

于 2012-08-29T16:08:41.210 回答