0

I am getting value through post method when i am add it into variable it is showing the same value but when i accessing the value from the outside. it showing me undefined.

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

1 回答 1

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');
                }
                });
于 2012-04-16T10:57:15.797 回答