我使用以下咖啡脚本加载 json
$.ajax jsonPath,
success : (data, status, xhr) =>
console.log("yea "+data)
this.currentIndex = 0;
this.imagesVO = data.images
this.imageManager = new ImageManager(data.images)
this.imagesCount = this.imagesVO.length
this.switchToImage(this.currentIndex)
error : (xhr, status, err) ->
$('#imageHolder').html("problem loading the json file, </br>make sure you are running this on your local server")
complete : (xhr, status) ->
#cconsole.log("comp")
json就是这样
{
"showName": "aaa",
"galleryName": "Season 3 Preview",
"images": [
{
"title": "Les goes shopping for a new car",
"url": "images/hcp_stills-0.jpeg",
"description": "Sailboats on the Charles River"
},
{
"title": "Les goes shopping for a new car",
"url": "images/hcp_stills-1.jpeg",
"description": "Sailboats on the Charles River"
},
{
"title": "Les goes shopping for a new car",
"url": "images/hcp_stills-2.jpeg",
"description": "Sailboats on the Charles River"
}]
}
在本地测试时,我像这样从 json 中获取图像数组,它可以工作 this.imageManager = new ImageManager(data.images)
但是,在服务器上进行测试时,chrome 抱怨 data.images 未定义,即使 json 加载正常。有任何想法吗?