我正在进行ajax调用并动态加载信息,即时从服务器获取图像名称,图像也在服务器上,当我在电脑上测试它工作正常时图像显示但是当我部署到我的手机时图像不存在......我能解决这个问题吗?
<script type="text/javascript">
$(document).ready(function(){
var parameters="userId="+ sessionStorage.getItem('userid');
var DResults="";
DResults = DataExchange(parameters,"WCR_TripRequest.php");
var Rdata = JSON.parse(DResults);
var content = '';
$.each(Rdata, function(i, post) {
var uids = (post.UserId);
var LTripId = (post.Tid);
var Name= (post.Name);
var Surname =(post.Surname);
var ppurl =(post.ppurl);
var DepStreetAddress = (post.$DepstreetAddress);
var DepSubTown =truncate(post.DepSubTown);
var DestStreetAddress=(post.DestStreetAddress);
var DestSubTown =truncate(post.DestSubTown);
var RequestRespYes="true";
var RequestRespNo="false";
content += '<li id="'+LTripId+'" class="collection-item avatar">'+
'<img src="http://***.***.59.45/ProfileImages/'+ppurl+'" alt="" class="circle">'+
'<span class="title" style="color:black"> <b><a href="W_Profile_ThirdParty.html">'+Name+' '+Surname+'</a></b>'+
'<br><center>Has requested to join you on your trip '+
'<br> <i class="fa fa-location-arrow"></i>'+DepSubTown+' - '+DestSubTown+'</span><br>'+
'<a id="AcceptTrip" onclick="PromptReply(\''+LTripId+'\',\''+RequestRespYes+'\',\''+uids+'\'); return false;" class="waves-effect waves-light btn"> <i class="fa fa-thumbs-up" aria-hidden="true"></i></a> '+
'<a id="RejectTrip" onclick="PromptReply(\''+LTripId+'\',\''+RequestRespNo+'\',\''+uids+'\'); return false;" class="waves-effect waves-light btn"> <i class="fa fa-thumbs-down" aria-hidden="true"></i></a></center>'+
'<a href="#!" class="secondary-content"><i class="material-icons"></i></a>'+
'</li>';
});
$(content).appendTo("#Searchlist");
//document.getElementById("my").style.display = "none";
//document.getElementById("tabheader").style.display = "visible";
});
</script>
答案 0 :(得分:1)
使用whitelist插件进行访问后,图片会显示,可帮助您放置iframe并显示在线图片。
$ cordova插件添加cordova-plugin-whitelist
$ cordova准备
添加此插件后,在config.xml
文件
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" /> <!-- Required for iOS9 -->
注意: origin="*"
和href="*"
可以访问所有网址。显示图片或iframe后,请按照the instructions