How to retrive Images from database using Jquery
I'm kind stuck on this. My situation: I have a Oracle database with a table where I store images (the file name,albumid, the mimetype of every file and the binary data in a BLOB plus a unique ID). Now what I'd like to achieve is to load all image from the database using AJAX and the GET method. Viewing a specific image using the
plugin, AJAX uses the returned data to fill an <ul> somewhere in the document, and that would be the freshly-loaded image.
Alright here's some code:
- $(window).load(function()
{
$.ajax({
type: "GET",
url: "RetriveIm",
dataType: "json",
success: function( data, textStatus, jqXHR)
{
if(data.success)
{
alert(console.log(data.imageInfo.name));
var items = [];
$.each(data, function(i, item)
{
items.push('<li><a href="#"><img src=data:image/png;base64,'+ item.imageInfo.thumbarray +' data-large=data:image/png;base64,' + item.imageInfo.fullarray + ' data-description=' + item.imageInfo.disc + ' alt=' + item.imageInfo.name + ' data-id='+ item.imageInfo.imageid +'/></a></li>'); // close each()
$('ul.es-carousel').append( items.join('') );
});
};
},
error: function(jqXHR, textStatus, errorThrown)
{
alert("error"+errorThrown);
console.log("Something really bad happened " + textStatus);
},
});
});
Servlet sends the data in array using json. Images are in base64 string format.
my problem is
when I run the code, it is not displaying the images in webbrowser. My server side code is in this
link. Please anyone help me to solve this. Please tell me what error have in my code. Thanks........