I have this code
我有这段代码
$.ajax({
type: "GET",
url: "/cgi-bin/ajax.pl",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: { "id" : id },
// ...
success: function(result){
if (result.error) {
alert('result.error: ' + result.error);
} else {
printObject(result);
}
}
});
where printObject
outputs
在printObject输出
responseText: Content-Type: application/json; charset=utf-8
{"276":"{\"var1\":[\"he\"],\"var2\":[\"he\",\"ki\",\"mt\"],\"var3\":\"07/06-2011\",\"var4\":[],\"var5\":\"ind\"}", ...
Question
问题
How do I iterate over this hash?
如何迭代这个散列?
Each array should just be treated as one variable. Ie. var2
would be he,ki,mt
.
每个数组应该被当作一个变量来处理。Ie。var2将他,吻,太。
1 个解决方案
#1
2
The result you got should already be parsed as json and it is available in result
object. Just do result.276.var2
to get the array.
您得到的结果应该已经被解析为json,并且在result对象中可用。只做result.276。var2获取数组。
#1
2
The result you got should already be parsed as json and it is available in result
object. Just do result.276.var2
to get the array.
您得到的结果应该已经被解析为json,并且在result对象中可用。只做result.276。var2获取数组。