設置我在我的網站下面的代碼:在對象參數不正確在JavaScript
function GroupObject(GroupID, GroupColor, GroupName, CalendarID, UserEnable, IrcChannel) {
this.uid = GroupID;
this.color = GroupColor;
this.groupname = GroupName;
this.calendarid = CalendarID;
this.userenable = UserEnable;
this.ircchannel = IrcChannel;
}
function GetGroupObjects(callback) {
var GlobalDB = [];
$.getJSON("Some Data From Google Docs",
function (data) {
$.each(data.feed.entry, function (i, entry) {
GlobalDB.push(new GroupObject(entry.gsx$uid.$t,
"000000",
SanitizeInputText(entry.gsx$group.$t),
SanitizeInputCalID(entry.gsx$calendarid.$t),
true,
SanitizeInputText(entry.gsx$ircchannel.$t)))
});
console.log(GlobalDB[0]);
console.log(GlobalDB[0].color);
callback(GlobalDB);
});
};
所有新創建的GlobalDB的參數與參數「色」的唯一例外是正確的。的console.log(GlobalDB [0])返回:
GroupObject
calendarid: "CalOfTNG"
color: "AB8B00"
groupname: "Austin TNG"
ircchannel: "AustinTNG"
uid: "TNG"
userenable: true
__proto__: GroupObject
它帶來相同的值用於彩色 「AB8B00」 在器和Firefox。任何想法爲什麼?從上面的代碼它應該是0. console.log(GlobalDB [0] .color)確實返回000000.但是,當我從回調中返回時使用GlobalDB 我再次獲得AB8B00。
用戶啓用,另一方面工作得很好。我只是無法找到什麼是因爲它在Chrome和Firefox中都失敗而導致參數.color的問題。
在此先感謝。
感謝您的回答! – Thelemitian