jquery tooltip获取未定义的值

时间:2012-04-16 10:31:46

标签: jquery-tooltip

当我将它添加到变量中时,我通过post方法获得值它显示相同的值但是当我从外部访问值时。它显示我未定义。

var Trends =this.$elm.data('title.poshytip');
        var value;
        var path = window.location.pathname;
              var name = path.substring(path.lastIndexOf('/') + 1);

                var dataToSend='{ID:"'+Trends+'"}';
                $.ajax({
                type: "POST",
                url: "UnitedStatesTrends.aspx/serverside",
                data: dataToSend,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                cache: false,
                success: function( data ) 
                {
                value =  data.d;

                },
                error: function() {
                alert('error');
                }
                })
//here                     
        alert(value);
    // here i am getting value=undefined in alert but my value is 'UnitedStates'

        this.$inner.append(
            typeof content == 'function' ?
                content.call(this.$elm[0], function(newContent) {
                    self.update(newContent);
                }) :



            //here i am setting the value to tooltip    

                content == '[title]' ? value : content
        );

1 个答案:

答案 0 :(得分:0)

嗯,我想,你忘了加一个分号;在此之后

 $.ajax({
                type: "POST",
                url: "UnitedStatesTrends.aspx/serverside",
                data: dataToSend,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                cache: false,
                success: function( data ) 
                {
                value =  data.d;

                },
                error: function() {
                alert('error');
                }
                });