{
"wordsacross": [
{"ACHE": [
{ "letter":"A" , "square":"A1" },
{ "letter":"C" , "square":"A2" },
{ "letter":"H" , "square":"A3" },
{ "letter":"E" , "square":"A4" }
]},
{"OPT": [
{ "letter":"O" , "square":"A6" },
{ "letter":"P" , "square":"A7" },
{ "letter":"T" , "square":"A8" }
]}
],
"wordsdown": [
{"ALPHA": [
{ "letter":"A" , "square":"A1" },
{ "letter":"L" , "square":"B1" },
{ "letter":"P" , "square":"C1" },
{ "letter":"H" , "square":"D1" },
{ "letter":"A" , "square":"E1" }
]},
{"BRO": [
{ "letter":"B" , "square":"G1" },
{ "letter":"R" , "square":"H1" },
{ "letter":"O" , "square":"I1" }
]}
]
}
$.ajax({
type: "POST",
url: "query.words.php",
data: { puzzleid: vPuzzleId },
async: false
}).done(function( msg ) {
vWords = JSON.parse( msg );
console.log(vWords);
console.log("There are "+vWords["wordsacross"].length+" words across");
for(var i=0;i<vWords["wordsacross"].length;i++)
{
console.log( vWords["wordsacross"][i].length );
console.log( vWords["wordsacross"][i][0]["square"] );
}
});
すべての正方形のアイテムの内容をコンソールに出力しようとしています。console.log での私の試みは両方とも未定義です。各正方形にアクセスしてコンソールに出力するにはどうすればよいですか?
前もって感謝します...