假设我从后端服务层得到了这些数据:
["2", "3", "7", "14"]
第一个问题是,这是否被视为有效的JSON数据? Json.org表示它是,但我在Google、SO等网站上找不到任何相关参考资料...
一个值列表。在大多数语言中,这被实现为数组、向量、列表或序列。
我想用jQuery将这些值添加到已存在的DropDownList对象OnLoad中。
$.getJSON("http://www.example.com/path-to-get-data", function(data) {
//iterate through each object and add it to the list.
//ideally, the key and value (string to display to the end user) would be the same.
});
我看了一下这个帖子,但它有对象,而不仅仅是一个数组。 我应该使用parseJSON
还是getJSON
?
提前致谢!