私はいくつかのjsonを読み込もうとしていて、それらの値を表示しています。
以下の JSON フィードがあり、 name 、 caption 、 type 、 id 、 email 値などのすべての値を読み取って出力できるようにしたいのですが、それらすべてに対して未定義になっています
///html
<div id="results"></div>
私のjsonは次のようになります
{
"action":"index.html",
"method":"post",
"html":[
{
"type":"fieldset",
"caption":"User information",
"html":[
{
"name":"email",
"caption":"Email address",
"type":"text",
"placeholder":"E.g. user@example.com",
"validate":{
"email":true
}
},
{
"name":"password",
"caption":"Password",
"type":"password",
"id":"registration-password",
"validate":{
"required":true,
"minlength":5,
"messages":{
"required":"Please enter a password",
"minlength":"At least {0} characters long"
}
}
},
{
"name":"password-repeat",
"caption":"Repeat password",
"type":"password",
"validate":{
"equalTo":"#registration-password",
"messages":{
"equalTo":"Please repeat your password"
}
}
},
{
"type":"radiobuttons",
"caption":"Sex",
"name":"sex",
"class":"labellist",
"options":{
"f":"Female",
"m":"Male"
}
},
{
"type":"checkboxes",
"name":"test",
"caption":"Receive newsletter about",
"class":"labellist",
"options":{
"updates":"Product updates",
"errors":{
"value":"security",
"caption":"Security warnings",
"checked":"checked"
}
}
}
]
},
{
"type":"fieldset",
"caption":"Address information",
"html":[
{
"name":"name",
"caption":"Your name",
"type":"text",
"placeholder":"E.g. John Doe"
},
{
"name":"address",
"caption":"Address",
"type":"text",
"validate":{ "required":true }
},
{
"name":"zip",
"caption":"ZIP code",
"type":"text",
"size":5,
"validate":{ "required":true }
},
{
"name":"city",
"caption":"City",
"type":"text",
"validate":{ "required":true }
},
{
"type":"select",
"name":"continent",
"caption":"Choose a continent",
"options":{
"america":"America",
"europe":{
"selected":"true",
"id":"europe-option",
"value":"europe",
"html":"Europe"
},
"asia":"Asia",
"africa":"Africa",
"australia":"Australia"
}
}
]
},
{
"type":"submit",
"value":"Signup"
}
]
}
私のコードは次のようになります。
$(document).ready(function() {
$('#letter-b a').click(function() {
$.getJSON('dformexternal.json', function(data) {
$('#results').empty();
$.each(data, function(entryIndex, entry) {
var html = '<div class="entry">';
html += '<h3 class="html">' + entry['html'] + '</h3>';
html += '<div class="name">' + entry['name'] + '</div>';
html += '<div class="caption">' + entry['caption'] + '</div>';
html += '<div class="type">' + entry['type'] + '</div>';
html += '<div class="definition">';
html += entry['definition'];
if (entry['name']) {
html += '<div class="name">';
$.each(entry['name'], function(lineIndex, line) {
html += '<div class="name">' + line + '</div>';
});
if (entry['caption']) {
html += '<div class="caption">' + entry['caption'] + '</div>';
}
html += '</div>';
}
html += '</div>';
html += '</div>';
$('#results').append(html);
});
});
return false;
});
});
どの値にもアクセスできないようです。私は何を間違えましたか?どんな助けでも素晴らしいでしょう。