该脚本应显示来自用户的帖子和图像。它在Xampp上运行良好,但在主机服务器上,我只看到帖子,而看不到用户发布的图像。它是空白的。在网络选项卡上也看不到。这是脚本部分:
var post = function(url){
$('#apost').show();
$('#apost').html('<i class="fa fa-circle-o-notch fa-spin afo"></i>');
$.ajax({
type: 'GET',
url: url,
success: function(data){
var template = $("#itemTemplate").html();
var result101 = Mustache.render(template, jQuery.parseJSON(data));
$(".post-content").html(result101);
$('#apost').hide();
},
complete: function(){
setInterval(post('ajax/post?page='+pagenum), 30000);
},
error:function(){
$('.don').html('error loading post');
}
});
};
这是html部分:
<div class="media-content">
<div>{{post}}</div>
{{#is_photo}}
<img src="uploads/scaled/{{photo44}}" alt="{{username}}" />
<p>{{caption}}</p>
{{/is_photo}}
</div>
最佳答案
您需要提供可从主机服务器访问的路径。主机服务器看到您的localhost
路径,并且如果镜像的目录树与本地服务器不同,则这是预期的行为,因为主机服务器的本地路径中没有任何内容。
两种方式:
localhost
... / ...),而是从这样的某个位置获取图像:static.yourproject.com/images/xyz.png