以下是代码
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
总是未定义并且它没有返回 ajax 请求我做错了什么?