jQuery的TagIt(自动完成)通过AJAX抓取JSON名单 [英] jQuery TagIt (autocomplete) Fetching JSON list via AJAX

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

问题描述

这是基于一个问题:<一href=\"http://stackoverflow.com/questions/6938802/trying-to-get-tag-it-to-work-with-an-ajax-call\">Trying获得标签它与一个AJAX调用工作

不过上面只为我创造了一个错误信息this.source是不是一个函数。

我试图让这个JSON列表显示为通过ajax tagit标记源。低于code:

  // Tagit
$(#标签)。tagit({
    tagSource:功能(){
        $阿贾克斯({
            网址:/admin/ajax.php?q=fetch_all_tags
            数据类型:JSON
            成功:功能(数据){
                的console.log(数据);
                返回的数据;
            }
        });
    }
});

Ajax调用返回:

  {4:PHP,2:HTML,3:CSS}


解决方案

此错误是由我使用的是旧版本标记它引起的。如果你得到同样的错误,确保您使用tagit最新版本的

This is a question based on: Trying to get tag-it to work with an AJAX call

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

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;
            }
        });
    }       
});

The ajax call returns:

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

解决方案

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天全站免登陆