zoukankan      html  css  js  c++  java
  • jQuery.ajax发送image请求格式

    1请求端

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <script src="/js/jquery-1.8.2.min.js"></script>
        <script>
            $(function () {
                $("#button").click(function () {
                    $.ajax({
                        type: "POST",
                        url: "/ajaximage.aspx",
                        data: "name=John&location=Boston",
                        mimeType: 'image/jpeg',
                        contentType: 'image/jpeg',
                        headers: {
                            "Accept": "image/webp,*/*;q=0.8"
                        },
                        success: function (msg) {
                            $("#message").html(msg);
                        }
                    });
                });
            });
             
        </script>
    </head>
    <body>
        <input id="button" type="button" value="button" />
        <div id="message"></div>
    </body>
    </html>

    2接收端

     public class ajaximage : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string parameter = new StreamReader(this.Request.InputStream).ReadToEnd();
                this.Response.ContentType = "image/jpeg";
                this.Response.Write(parameter);
            }
        }
  • 相关阅读:
    [Apio2014]回文串
    省队集训day6 C
    省队集训day6 B
    省队集训Day3 light
    省队集训Day3 tree
    多串匹配
    ubuntu卸载福昕阅读器
    greenlet
    python multithread task_done
    mysql参数调优
  • 原文地址:https://www.cnblogs.com/qiyebao/p/5114105.html
Copyright © 2011-2022 走看看