Reputation: 1061
I am using web api to get the image from database, it is returning json data, now the image data which is coming in response is like this
�PNG
���
IHDR��@������ ����sRGB�������gAMA�����a��� pHYs�������o�d����IDATx^����\�uލ�x����q��N^�q��q��%v��n�H�,Y�7J"A�N��H���{�� :H�$A��wi��g���9w��H�,�u��9s�����yֳ��}��#�Á�1b��9�Ks
���S��1b��9s �@/́�������1b��9�ss �(&}�M�^���5~���9s���
�
how should i convert it back, so that i can see image in my browser , using jquery
current ajax is
$.ajax({
url: "/api/v1/images/" + items.image.id + "/w" + items.image.width,
type: 'GET',
dataType: 'json',
success: function (data) {
$('#' + items.id).attr('src',data.responseText);
},
error: function (status) {
}
});
Upvotes: 1
Views: 1751
Reputation: 22518
Just do this, it's easier than you think
var url = '/api/v1/images/' + items.image.id + '/w' + items.image.width;
$('#' + items.id).attr('src', url);
No need for ajax at all.
Upvotes: 2