我的 javascript 有问题,我调用了一个返回此字符串的 ajax 方法:
{
"ObjectResponse": {
"Operation": "OK",
"Response": "SUCCESS",
"Message": "List of AAA Found",
"List": [
{
"keySource": "gat\/images\/images_set\/apple.jpg",
"idSiteKey": "1",
"text": "Apple"
},
{
"keySource": "gat\/images\/images_set\/cat.jpg",
"idSiteKey": "2",
"text": "Cat"
},
{
"keySource": "gat\/images\/images_set\/coffee.jpg",
"idSiteKey": "3",
"text": "Coffee"
},
{
"keySource": "gat\/images\/images_set\/dog.jpg",
"idSiteKey": "4",
"text": "Dog"
},
{
"keySource": "gat\/images\/images_set\/horse.jpg",
"idSiteKey": "5",
"text": "Horse"
},
{
"keySource": "gat\/images\/images_set\/police.jpg",
"idSiteKey": "6",
"text": "Police"
},
{
"keySource": "gat\/images\/images_set\/tree.jpg",
"idSiteKey": "7",
"text": "Tree"
}
]
}
}
我以这种方式评估内容:
xhr.onreadystatechange = ensureReadiness;
....
responseText = xhr.responseText;
如果我尝试在 javascript 上解析它:
response = JSON.parse(responseText);
如果我访问一个属性,response.ObjectResponse.Operation
我确实得到了正确的内容..但是当我尝试访问列表时它总是刹车
如果我尝试相同的字符串,但不是调用服务,而是将内容分配给它可以工作的 var,我确实可以访问列表
var myTemporalString ='{"ObjectResponse":{"Operation":"OK","Response":"SUCCESS","Message":"List of Keys Found","List":...';
response.JSON.parse(myTemporalString);
任何建议为什么会发生这种情况?