zoukankan      html  css  js  c++  java
  • ajax 请求二进制流 图片

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>ajax 请求二进制流图片</title>
        <script src="Scripts/jquery.min.js" type="text/javascript"></script>
        <script src="Scripts/boot.js" type="text/javascript"></script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="imgcontainer">
        </div>
        </form>
    </body>
    </html>
    <script language="javascript" type="text/javascript">
        var url = bootPATH + "../server/images/1.png";
        var xhr = new XMLHttpRequest();
        xhr.open('GET', url, true);
        xhr.responseType = "blob";
        xhr.setRequestHeader("client_type", "DESKTOP_WEB");
        xhr.onload = function () {
            if (this.status == 200) {
                var blob = this.response;
                var img = document.createElement("img");
                img.onload = function (e) {
                    window.URL.revokeObjectURL(img.src);
                };
                img.src = window.URL.createObjectURL(blob);
                $("#imgcontainer").html(img);
            }
        }
        xhr.send();
    </script>

  • 相关阅读:
    The while statement
    App server 与 Web server之间的区别
    Keyboard input
    Recursion
    Conditionals
    TurtleWorld Exercises
    Python TurtleWorld configuration and simple test
    Why functions
    The python programing language
    性能测试3 方法
  • 原文地址:https://www.cnblogs.com/nxxshxf/p/5226373.html
Copyright © 2011-2022 走看看