有人可以帮我用 JQuery 获取 JSON 吗?我想我在我的 JQuery 代码中犯了一些错误。任何帮助将不胜感激。下面是我的 JSON 和 JQuery:
JSON:
{
"video": [
{
"id": "12312412312",
"name": "Ecuaciones Diferenciales",
"url": "/video/math/edo/12312412312",
"author": {
"data": [
{
"name_author": "Alejandro Morales",
"uri": "/author/alejandro-morales",
"type": "master"
}
]
},
"comments": {
"data": [
{
"id": "367501354973_12216733",
"from": {
"name": "Doug Edwards",
"id": "628675309"
},
"message": "Make sure you don't, as they say, go whole hog...\nhttp://www.youtube.com/watch?v=U4wTFuaV8VQ",
"created_time": "2010-03-06T03:24:46+0000"
},
{
"id": "367501354973_12249673",
"from": {
"name": "Tom Taylor",
"id": "1249191863"
},
"message": "Are you and Karen gonna, as they say, pig out?",
"created_time": "2010-03-06T21:05:21+0000"
},
{
"id": "367501354973_12249857",
"from": {
"name": "Sheila Taylor",
"id": "1315606682"
},
"message": "how did it turn out? Sounds nummy!\n",
"created_time": "2010-03-06T21:10:30+0000"
}
]
}
},
{
"id": "12312412311",
"name": "Ecuaciones Diferenciales : El arte de las diferenciaciones",
"url": "/video/math/edo/1231241231212",
"author": {
"data": [
{
"name_author": "Alejandro Morales",
"uri": "/author/alejandro-morales",
"type": "master"
}
]
},
"comments": {
"data": [
{
"id": "367501354973_12216733",
"from": {
"name": "Doug Edwards",
"id": "628675309"
},
"message": "Make sure you don't, as they say, go whole hog...\nhttp://www.youtube.com/watch?v=U4wTFuaV8VQ",
"created_time": "2010-03-06T03:24:46+0000"
},
{
"id": "367501354973_12249673",
"from": {
"name": "Tom Taylor",
"id": "1249191863"
},
"message": "Are you and Karen gonna, as they say, pig out?",
"created_time": "2010-03-06T21:05:21+0000"
},
{
"id": "367501354973_12249857",
"from": {
"name": "Sheila Taylor",
"id": "1315606682"
},
"message": "how did it turn out? Sounds nummy!\n",
"created_time": "2010-03-06T21:10:30+0000"
}
]
}
}
]
}
jQuery 代码
var url = 'result.json';
$(document).ready(function() {
$.getJSON(url, function(data) {
$.each(data, function(video, data) {
$('#stage').html('<p> ID:' + data.video + '</p>');
$('#stage').append('<p Name: ' + data.name+ '</p>');
$('#stage').append('<p> URL: ' + data.url+ '</p>');
console.log("========================");
console.log(data);
});
});
});