码迷,mamicode.com
首页 > Web开发 > 详细

jQuery.ajax发送image请求格式

时间:2016-01-08 18:39:10      阅读:341      评论:0      收藏:0      [点我收藏+]

标签:

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);
        }
    }

 

jQuery.ajax发送image请求格式

标签:

原文地址:http://www.cnblogs.com/qiyebao/p/5114105.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!