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);
關注公衆號,瞭解更多資訊