1
我調用了ajax服務,並收回了對象的集合。物品(A)物業是組,訂單,工資。假設我的對象是[Employee, 1, 1500],[Management, 2, 2000], [Employee, 3, salary]
。基於對象屬性的數組和變量名稱的數組
我需要爲每組可以容納不同的對象(B)創建一個數組,這些對象可以具有格式[OrderNo, String]
並將被AJAX調用也檢索。如果已經創建了組的數組,我不想再爲它調用ajax。
問題是物體(A)或(B)是事先不知道的號碼,我必須能夠引用(A)對象陣列和列表通它們。
結果在僞代碼
var groups = [
Employee: [[1372, "Free meals"],[947, "Lower salary"],[21, "Overtimes"],[74667,"Great Xmass party"]],
Management: [[11, "Responsibility"],[485,"Extra meetings"]]
]
我不知道如何正確地寫
for(var index in "Object A"){
if(groups.AlreadyContains("Object A[index]")){
do nothing;
}
else {
var "Object A[index]" = MyAjaxCall("Object A[index]");
groups.AddAnArray("Object A[index]");
}
}
function MyAjaxCall(par){ call ajax and return collection of B objects;}
foreach(var i in groups.Management)
{Console.log(Management[i].PropertyName);}
控制檯輸出:責任,額外的會議