我遇到的问题是我的代码确认要引入正确的对象。但是,当我测试文件时,图像根本没有被拉入。我已经仔细检查了,我得到了404响应,但文件存在于正确的目录中。
//JSON OBJECT SAMPLE IS BELOW, A SEPARATE FILE....
var reviews = [{
Id: "ajjhwejkssl",
Title: "The little camera that could!",
Rating: 5,
Body: "TEXT HERE",
CreateDate: new Date(2012, 5, 23, 14, 12, 10, 0),
Owner: {
Id: "kwergiueerwq",
Name: "Bugs Bunny",
Url: "./users.html?id=kwergiueerwq",
AvatarImage: "./avatars/bugsbunny.jpg",
IsFeaturedReviewer: false,
CreateDate: new Date(2012, 2, 12, 9, 44, 0, 0)
}
}
]
//CODE
var data = reviews;
$(document).ready(function () {
//console.log("browser: " + browser);
for (var i = 0; i < data.length; i++) {
try {
//CREATE NEW REVIEW DIV
var reviewPost = "<div class='review'><div class='clear'></div><div class='content'><div class='datePosted'>" + data[i].CreateDate + "</div><div class='avatar'><div class='header'><div class='rating'><img src='images/star-sprite.png'/><img src='images/star-sprite.png'/><img src='images/star-sprite.png'/><img src='images/star-sprite.png'/><img src='images/star-sprite.png'/></div></div><div class='clear'></div><div class='title'>" + data[i].Title + "</div><div class='memberImg'><img id='thumb' src=" + data[i].Owner.AvatarImage + "/></div><div id='member'><div class='reviewedBy'>Reviewed by <a href='' class='member'>" + data[i].Owner.Name + "</a></div><div class='membership'>Member Since " + data[i].Owner.CreateDate + "</div></div></div></div><div class='clear'></div><div class='message'>" + data[i].Body + "</div></div><div class='clear'></div>";
if (data[i].Rating != null) {
console.log("Rating: " + data[i].Rating);
}
//adds reviewPost inside of reviews
review.append(reviewPost);
//document.write(reviewPost);
} catch (e) {
console.log("error: " + e);
};
}
});
任何想法和建议都会很棒。
答案 0 :(得分:0)
正如我所了解的那样,路径中的点无关紧要,但是:
另外,请确保avatars目录实际上位于您的Web目录的根目录中。