Spring 正在返回一个具有四个属性的 json 编码对象。其中之一是名为“array”的属性。我想要这个数组的内容。
这是整个 json 响应:
ee
{"map":null,"array":[{"id":2,"description":"Cloud For Dev","businessSize":2,"businessType":9,"businessLocation":3},{"id":3,"description":"Cloud For Prod","businessSize":2,"businessType":9,"businessLocation":3}],"string":null,"bool":false}
0
我实际上不确定“ee”或 0 是什么意思......无论如何,我试图像这样解析它:
$.ajax({
type: "GET",
url: "/ajax/rest/teamService/list",
dataType: "json",
success: function (response) {
var teamArray = response.array;
var $el = $("#teamSelect");
$el.empty();
$.each(teamArray[0], function(team) {
alert(team.description);
$el.append($("<option></option>").attr("value", team.id).text(team.description));
});
// Reattach the plugin
$("#teamSelect").selectbox("detach");
$("#teamSelect").selectbox("attach");
},
error: function (jqXHR, textStatus, errorThrown) {
if (textStatus === 'error') {
setTimeout(function() { window.location = '/do/login'; }, 7000);
}
}
});
而且我弹出警报框 6 次(应该是 2 次),每次都显示“未定义”而不是实际描述。
选择框本身有四个空选项。
好像我正在迭代 json 编码对象的四个参数,而不是封闭数组的两个内容。
我怎样才能解决这个问题?