var ArrComList; try { //接口傳進來的數據格式為 A,B,C,D,這里根據逗號分隔返回數組。 ArrComList = WeighControl.GetComList().split(','); } catch (e) { } var s = ""; //循環將數組轉換為Json格式。 for (var i = 0; i < ArrComList.length; i++) { if (s.length > 0) { s += "," }; s += "{\"id\":" + i + ",\"text\":\"" + ArrComList[i] + "\"}"; } s = eval("[" + s + "]"); //將Json的數據賦值給Combox $("#weighInterface").combobox("loadData", s);