Following is the code
 function CreateDiv(D) {
  D.body = function () {
            var d;
             $.ajax({
                type: "GET",
                url: "Default.aspx",
                data: 'ExtrFlag=GetChat&userID=1&FriendID=' + this.id,
                success: function (data) {
                    d= data.split('@@@')[0]);
                },
                error: function (xhr) {
                   alert(xhr.responseText);
                }
            });
   var reutnData = "<div class='chatBody' id='chatBody" + this.id + "' >"+d+"</div>";
            return reutnData;
        };
       D.create = function () {
            var exist = $("#Container").find("div[id=chatbox" + this.id + "]");
            if (exist.length == 0) {
                   var ToAppend = "<div id='chatbox" + this.id + "' style='" +  D.style() + "' class='chatboxclass' >" + D.header() +D.body()+ "</div>";
                $("#Container").append(ToAppend);
                align++;
            }
        };
        return D;
    }
 function NewChat(id,username,picture) {
        var div = new CreateDiv({ width: 250, height: 285, id: id, username: username, picture: picture });
        div.create();
    }
d is always undefined and it's not returning the ajax request what am I doing wrong ?
 
     
    