我想从网络服务中获取图片。与Web服务的连接已成功完成,但图像未在我的页面中打开。 我得到的链接是我要打开的图像的链接。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PhoneGap</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script type="text/javascript" charset="utf-8" src="js/Config/phonegap-0.9.3.js"></script>
<link rel="stylesheet" href="css/jquery/jquery.mobile-1.0a1.min.css" />
<script>
var ws_key="....";
var PHP_AUTH_USER="....";
var request = new XMLHttpRequest();
request.open("GET","http://patisserie-orient.fr/prestashop/prestashop/api/images/products/10/50?PHP_AUTH_USER="+PHP_AUTH_USER+"&ws_key="+ws_key,true);
request.onreadystatechange = function()
{
if(request.readyState==4)
{
alert("Status is: "+request.status);
if (request.status == 200 || request.status == 0)
{
response = request.responseXML;
lien="http://patisserie-orient.fr/prestashop/prestashop/api/images/products/10/50"
}
}
}
request.send();
</script>
</head>
<body>
<img src=lien height="150" width="150">
</body>
</html>
答案 0 :(得分:1)
您可以在HTML中执行此操作。
<img src="http://patisserie-orient.fr/prestashop/prestashop/api/images/products/10/50?PHP_AUTH_USER=yourpassword&ws_key=yourlogin ">