0
我需要在一个Ajax调用充分利用对象的值在JavaScript
代码段
$.each(responseJson.slice(0,7), function (index) {
var resp_JSON=responseJson[index];
console.log(resp_JSON);
在控制台从响应对象获取值帮助resp_JSON
是Object {17130003: "A message string from the cache"}
现在响应的Json没有名称标签,所以我可以做resp_JSON.id
或&获取值。它只是有价值。
我试图
resp_JSON[0];
//错误
resp_JSON.Object[0];
//错误
我需要在两个单独的JavaScript变量获取17130003
& A message string from the cache
。
其实你需要访问'resp_JSON ['17130003']',如果这些键是动态的,你可以使用'Object.values(resp_JSON)'和'Object.keys(resp_JSON)' –
@HassanImam感谢兄弟的工作。 – underdog