Is it possible, or reasonable, to encode bitmap data in JSON to return to the web service?
Update: Yes, this worked better than I thought. I created a .NET compound object to combine images with image data
Public class AllThumbnails Public imgAllThumbs As String Public Positions () as Drawing.Rectangle Final Class
and access it through jQuery AJAX:
$.ajax({ type: "POST", url: "WebService.asmx/makeAllThumbnailsImage", data: "{DocumentNumber : \"" + DocumentNumber + "\"} ", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var adl = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; var data = Base64.decode(adl.imgAllThumbs); $('#output').append("<p><strong>" + data.length + "</strong></p>"); $('#output').append("<p><strong><i>" + adl.positions.length + "<i></strong></p>"); }, failure: function (msg) { $('#output').text(msg); } });
I had to increase the value in my web.config since my image data exceeded the standard jsonSerialization buffer:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength = "262144">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
Thanks guys for your help.
Jon DellOro
source share