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);
原文地址:http://www.cnblogs.com/allen0118/p/3852689.html