EXTERNAL json ファイルのオブジェクトの配列に JavaScript 配列を割り当てるにはどうすればよいですか?
これが私が試したことです。
JavaScript スニペット
var i = 0;
var testjson = $.getJSON('/TestJSON');
jsonObj = JSON.parse(testjson);
$("#testJSONBtn").click(function () {
while (i <= jsonObj.events.length) {
$("#JSONOutput").append(jsonObj.events[i].title + ", " + jsonObj.events[i].date + ", " + jsonObj.events[i].explanation + "<br/>")
i += 1;
}
});
JSON ファイルの内容
{
"events":
[
{"title":"Okmulgee Public Schools Starts 3rd Quarter" , "date":"1-2-2013" , "explanation":"Okmulgee Public Schools begins its third quarter."}
{"title":"Okmulgee Public Schools-Closed in Observance of Martin Luther King Jr. Holiday" , "date":"1-21-2013" , "explanation":"The Okmulgee Public Schools will be closed in observance of the Martin Luther King Jr. holiday."}
{"title":"Okmulgee Public Schools County Professional Day" , "date":"2-1-2013" , "explanation":"Okmulgee Public Schools County Professional Day is today."}
]
}
私は何を間違っていますか?