从web服务获取图像

Get an image from a web service

本文关键字:图像 获取 服务 web      更新时间:2023-09-26

我想从web服务中获取一个图像。与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>

您可以在HTML中执行此操作。

<img src="http://patisserie-orient.fr/prestashop/prestashop/api/images/products/10/50?PHP_AUTH_USER=yourpassword&ws_key=yourlogin ">