使用jquery.ajax()从客户端的Web服务获取图像并显示为aspx [英] using jquery.ajax() to get image from webservice in client side and display in aspx

查看:160
本文介绍了使用jquery.ajax()从客户端的Web服务获取图像并显示为aspx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#Button3").click(function (e) {
                e.preventDefault();

                sendData3();
            });

            function sendData3() {
                $.support.cors = true;
                $.ajax({
                    type: "POST",
                    url: "http://localhost/imageRetrieve/Service1.asmx/GetImage",
                    data: "{ 'image_id' : 1 }",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: Success3,
                    error: Error3
                });
            }
            function Success3(data) {

// this fuction is called but i am not sure what to write here to retrieve the image

}
function Error3(request, status, error) {

                alert("error3");
                $("#label1").html(request.statusText);
            }


以下是当我从浏览器访问" http://localhost/imageRetrieve/Service1.asmx/GetImage时得到的结果
< base64Binary> QzpcVXNlcnNcUHVibGljXFBpY3R1cmVzXFNhbXBsZSBQaWN0dXJlc1xDaHJ5c2FudGhlbXVtLmpwZw ==</base64Binary>

json的响应正文为:

{ d":[67,58,92,85,115,101,114,115,92,80,117,98,108,105,99,92,80,105,99,116,117,114,101,115,92,83,97,109,112,108,101,32,80,105,99,116,117,114,101,115,92,67,104,114,121,115,97,110,116,104,101,109,117,109,46,106,112,103]}



我不知道如何获取图像.

请帮助:(


Below is the result i get when i access ""http://localhost/imageRetrieve/Service1.asmx/GetImage" from browser

<base64Binary>QzpcVXNlcnNcUHVibGljXFBpY3R1cmVzXFNhbXBsZSBQaWN0dXJlc1xDaHJ5c2FudGhlbXVtLmpwZw==</base64Binary>

the response body from json is :

{"d":[67,58,92,85,115,101,114,115,92,80,117,98,108,105,99,92,80,105,99,116,117,114,101,115,92,83,97,109,112,108,101,32,80,105,99,116,117,114,101,115,92,67,104,114,121,115,97,110,116,104,101,109,117,109,46,106,112,103]}



I dont know how to get the image.

please help :(

推荐答案

(" ).click(函数(e){ e.preventDefault(); sendData3(); }); 函数sendData3(){
("#Button3").click(function (e) { e.preventDefault(); sendData3(); }); function sendData3() {


.support.cors = true ;
.support.cors = true;


.ajax ({ 类型:" , url:" , 数据:" , contentType:" , dataType:" , 成功:Success3, 错误:Error3 }); } 函数Success3(data){ // 称为此功能,但我不确定在此处写些什么来检索图像 } 函数Error3(请求,状态,错误){ alert(" );
.ajax({ type: "POST", url: "http://localhost/imageRetrieve/Service1.asmx/GetImage", data: "{ 'image_id' : 1 }", contentType: "application/json; charset=utf-8", dataType: "json", success: Success3, error: Error3 }); } function Success3(data) { // this fuction is called but i am not sure what to write here to retrieve the image } function Error3(request, status, error) { alert("error3");


这篇关于使用jquery.ajax()从客户端的Web服务获取图像并显示为aspx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆