title: How to get ajax response in jquery?
body: <p>Following is the code</p>
  
  <pre><code> function CreateDiv(D) {
  
    D.body = function () {
              var d;
  
               $.ajax({
                  type: "GET",
                  url: "Default.aspx",
                  data: 'ExtrFlag=GetChat&amp;userID=1&amp;FriendID=' + this.id,
                  success: function (data) {
  
                      d= data.split('@@@')[0]);
  
                  },
                  error: function (xhr) {
                     alert(xhr.responseText);
  
                  }
              });
     var reutnData = "&lt;div class='chatBody' id='chatBody" + this.id + "' &gt;"+d+"&lt;/div&gt;";
              return reutnData;
          };
         D.create = function () {
              var exist = $("#Container").find("div[id=chatbox" + this.id + "]");
              if (exist.length == 0) {
  
                     var ToAppend = "&lt;div id='chatbox" + this.id + "' style='" +  D.style() + "' class='chatboxclass' &gt;" + D.header() +D.body()+ "&lt;/div&gt;";
                  $("#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();
      }
  </code></pre>
  
  <p><code>d</code> is always undefined and it's not returning the ajax request what am I doing wrong ?</p>