【问题标题】:Tag-it jquery: get tags from the webserivceTag-it jquery:从 Web 服务获取标签
【发布时间】:2012-05-03 18:30:44
【问题描述】:

我正在尝试从 web 服务获取 tag-it 标签,问题是我什至可以成功,警报永远不会出现,错误事件也不会出现。

    $('#singleFieldTags').tagit({
    //availableTags: sampleTags,
    // This will make Tag-it submit a single form value, as a comma-delimited field.
    singleField: true,
    placeholderText: "Start typing your tags...",
    singleFieldNode: $('#ContentPlaceHolder1_hidTags'),
    availableTags: function () {
        $.ajax({
            url: "WServices/TypeService.asmx/getTags",
            type: "POST",
            data: JSON.stringify({ para_Parent_Name: "tags" }),
            dataType: "json",
            async: true,
            success: function (data) {
                console.log(data);
                alert(data);
                return data;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("errer");
                debugger;
            }
        });
    }
});

【问题讨论】:

    标签: javascript jquery asp.net tag-it


    【解决方案1】:

    确保返回有效的 JSON。我将准确地返回返回的内容(通过 FireBug/开发工具)并将其放入 http://jsonlint.com/ 以查看它是否有效。

    我提供这个作为答案是因为我们在 jQuery 的主要版本之间切换时遇到了很大的问题。我们所有的 AJAX 东西都坏了。我们最终发现这是返回的 JSON。如果它无效,那么 jQuery 将静默失败。

    希望这为寻找解决方案提供了一个可能的起点。

    【讨论】:

      猜你喜欢
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多