0

我遇到了一个问题,我的代码承认要拉入的正确对象。但是,当我测试我的文件时,根本没有拉入图像。我已经仔细检查并收到 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);
        };
    }
});

任何想法和建议都会很棒。

4

1 回答 1

0

正如我所知,路径中的点无关紧要,但是:

此外,请确保头像目录实际上位于您的 Web 目录的根目录中。

于 2013-04-25T14:29:42.380 回答