jQuery TagIt(自动完成)通过 AJAX 获取 JSON 列表 [英] jQuery TagIt (autocomplete) Fetching JSON list via AJAX

查看:13
本文介绍了jQuery TagIt(自动完成)通过 AJAX 获取 JSON 列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个基于的问题:试图让 tag-it 与 AJAX 调用一起工作

然而,上面只是为我创建了一个this.source is not a function"的错误消息.

However the above just creates an error message of 'this.source is not a function' for me.

我试图通过 ajax 使这个 json 列表显示为 tagit 的标记源.代码如下:

I am trying to get this json list to appear as the tag source for tagit via ajax. Code below:

// Tagit
$("#tags").tagit({      
    tagSource: function() {
        $.ajax({
            url: "/admin/ajax.php?q=fetch_all_tags",
            dataType: "json",
            success: function(data) {
                console.log(data);
                return data;
            }
        });
    }       
});

ajax 调用返回:

{"4":"php","2":"html","3":"css"}

推荐答案

此错误是由于我使用旧版本的 tag it 造成的.如果您遇到同样的错误,请确保您使用的是最新版本的 tagit

This error was caused by me using an old version of tag it. If you get the same error make sure you are using the newest version of tagit

这篇关于jQuery TagIt(自动完成)通过 AJAX 获取 JSON 列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆