so this is my 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) {
                         var StrResponse;
                         StrResponse = data.split('@@@');
                         return StrResponse[0];
                     },
                     error: function (xhr) {
                         return xhr.responseText;
                     }
                 });
            alert(d);
            return "<div class='chatBody' id='chatBody" + this.id + "' >" + d + "</div>";
     };
 }
 function NewChat(id,username,picture) {
        var div = new CreateDiv({ width: 250, height: 285, id: id, username: username, picture: picture });
        div.create();
    }
the problem is when the ajax call is executed the result is d=[object object] but in my case it should be a string because the ajax server side function always returns a string.
 
     
     
    