誰かが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);
});
});
});