jQueryでJSONファイルを読み込もうとしています:
var listOfItems;
$(function() {
$.getJSON('myData.json', function(data) {
listOfItems = data.items;
});
});
これはmyData.jsonです:
{
{"source": "Microsoft", "target": "Amazon", "type": "licensing"},
{"source": "Microsoft", "target": "HTC", "type": "licensing"},
{"source": "Samsung", "target": "Apple", "type": "suit"},
{"source": "Motorola", "target": "Apple", "type": "suit"}
}
listOfItems
ただし、Chrome Web Developerは、このコードの後には未定義であると述べています。なんで?javascript、HTML、JSONファイルの両方が同じディレクトリにあると確信しています。