1, test.json
{
"key1": "value1",
"key2":
{
"key3": "value3",
"key4":
[
{"value": "name", "event": "function"}
]
}
}
2,js文件
$.ajax({
method:'post',
url:'test.json',
dataType:'json',
success:function(data)
{
var test = data["key2"]["key4"][0];
alert(test);
for(var key in test)
{
alert(test[key]);
}
//alert(data["key2"]["key4"][0]["value"]);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
}
});