如何从Jason响应格式获取图像? [英] How Get Image From Jason Response Format?

查看:65
本文介绍了如何从Jason响应格式获取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请Helppppppppp我,



i明天早上必须完成我的任务:(我刚接触到angularjs,我创建了一个表格,用于向服务器(webservice)发送数据保存在我的数据库中,我保存了这样的图像

Please Helppppppppp Me ,

i have to deliver my task tomorrow morning :( iam new to angularjs , i created a form for sending data to server(webservice) to save it in my database , i saved image like this

$scope.InsertRecord = function () {
        var filedata;
        var f = document.getElementById('file').files[0], r = new FileReader();
        alert(f.length);
        r.onloadend = function (e) {
            filedata = e.target.result;
            //console.log(filedata.length)
            $.ajax({
                type: "POST",
                url: "service.asmx/insertMethod",
                data: "{'title':'" + $scope.news_title + "','desc':'" + $scope.news_content + "' , 'Img':'" + filedata + "'}",
                contentType: "application/json; charset=utf-8",
                //dataType: "application/json",
                success: function (msg) {
                    alert("Inserting Done");
                },
                error: function (xhr,status,error) {
                    alert("ERROR MESSAGE :" + error);
                }
            });

            ResetValues();
        }
        r.readAsDataURL(f);





现在iam以jason格式检索它,它就像这样[{Image:{Length:2345}}]



i不要知道如何转换为图像





请帮助meeee



now iam retrieved it on jason format and it like this [{Image:{Length:2345}}]

i don't know how to convert to image


please help meeee

推荐答案

scope.InsertR ecord = function (){
var filedata;
var f = document .getElementById(' file')。files [ 0 ],r = new FileReader();
alert(f.length);
r.onloadend = function (e){
filedata = e.target.result;
// console.log(filedata.length)
scope.InsertRecord = function () { var filedata; var f = document.getElementById('file').files[0], r = new FileReader(); alert(f.length); r.onloadend = function (e) { filedata = e.target.result; //console.log(filedata.length)


.ajax({
type: POST
url : service.asmx / insertMethod
data: {'title':' +
.ajax({ type: "POST", url: "service.asmx/insertMethod", data: "{'title':'" +


scope.news_title + ','desc':' +
scope.news_title + "','desc':'" +


这篇关于如何从Jason响应格式获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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