ich zur Ausgabe versucht, den „Titel“, „url“, „imageUrl“ aber es zeigt nur „unbestimmt“ oder „[object Object]“ und ich habe diesejQuery Json nicht ausgibt den richtigen Wert
Mein Code lösen ausgeben soll wie folgt aus:
<p>The Word</p>
<p>Art</p>
<p>Attaining</p>
Hier ist meine JSON-Code:
{
"ebookList":{
"ebook":[
{
"title":"The Word",
"url":"/products/",
"imageUrl":"/products/",
"_id":"1"
},
{
"title":"Art",
"url":"/products/",
"imageUrl":"/products/",
"_id":"2"
},
{
"title":"Attaining",
"url":"/products/",
"imageUrl":"/products/",
"_id":"3"
}
]
}
}
und mein Java Skript:
function loadBooks() {
$.getJSON('products/books.json', function (result) {
$.each(result, function (i, res) {
alert(res.title);
});
});
}
'$ .each (result.ebookList.ebook, Funktion (i, res) { alert (res.title); });' oder '$ .each (Ergebnis [ 'ebookList'] [ 'ebook' ], Funktion (i, res) { alert (res.title); }); ' –
Also, es wird das gleiche wie die anderen Eigenschaften sein. – jazz