c# - Qtip数据未定义错误

标签 c# javascript asp.net json qtip2

我正在使用Qtip工具提示和我的内容来自 JSON。 当我单击工具提示显示内容时,在检查 chrome 中的元素时收到“数据未定义”错误。

这是我的 JavaScript 代码。

 $('#accordion_functions ul li a span:nth-child(2)').each(function () {    
  $(this).qtip({
        content: {
    text: function(event,api) {
        $.ajax({
            url: 'http://localhost:51783/Help/GetHelpText.ashx', 
            type: 'GET',
            dataType: 'json', 
           data: {
             id: $(this).attr('id') // Pass through the ID span
            },                  
        })
        .then(function(content) {

            var content = 'Help' + data.Text;                                
            api.set('content.text', content);

        }, function(xhr, status, error) {

            api.set('content.text', status + ': ' + error);
        });

        return 'Loading' // Set some initial loading text
    }
},
        hide: {
            event: 'click',
            fixed: true,
            delay: 50
        },
        show: {
            event: 'click',
            solo: true
        },
        events: {
            show: function (event, api) {
                $(api.elements.target).addClass('highlight');
            },
            hide: function (event, api) {
                $(api.elements.target).removeClass('highlight');
            }
        },
        style: {                
            width: 1200,
            padding: 5,
            tip: 'bottomRight',
        },
        position: {
            my: 'bottom right',
            at: 'bottom middle'
        }
    });

通过 url 发布的数据如下所示:

[{"id":"PCG01","Form":"Party Company","Tab":"General","Text":"Help needed here"},{"id":"PCG02","Form":"Party Company","Tab":"Contact","Text":"This is a second help"},{"id":"PCG03","Form":"Party Company","Tab":"Settlement","Text":"Third help"},{"id":"PCG04","Form":"Party Company","Tab":"Client","Text":"Fourth help"},{"id":"PCG05","Form":"Party Company","Tab":"Trade Constraints","Text":"Fifth help"},{"id":"PCG06","Form":"Party Company","Tab":"Attachments","Text":"Sixth help"}]

我可能做错了什么?

最佳答案

不是在.then

中吗
    .then(function(content) {

        var **contentText** = 'Help' + **content**.Text;                                
        api.set('content.text', **contentText**);

关于c# - Qtip数据未定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17613041/

相关文章:

c# - 如何将凸曲线拟合到一组数据点

c# - 递归检查数组中是否有重复元素

c# - 如何创建包含一个字符串变量和三个 int 变量的字典

javascript - 使用 javascript 隐藏 div,直到按下按钮

javascript - AngularJS 指令 : How do I hide the alert using timeout?

c# - 如何使用 linq 从表中获取最大字符串长度列行?

javascript - Angular2 文档 - 分层依赖注入(inject)器(恢复服务)

c# - 无论如何修复 ASP.NET gridview 中的列宽

c# - 名为 'DefaultApi' 的路由已经在路由集合中

c# - 如何检查是否从 GridView 中选择了任何行?