0

I want to get a gif image from server by clicking a button in my asp.net website, based on Ajax.The Gif changes dynamically each time before sended by server(Actually I want to refresh an image). I tried this javascript but did not help me:

<script>
function loadXMLDoc() {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("img1").innerHTML = 'data:image/Gif;base64,' + xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", "images/img.gif", true);
    xmlhttp.send();
}

I also tried .src instead of .innerHTML and remove 'data:image/Gif;base64,' but non of them helped. The output is like this:

data:image/Gif;base64,GIF89a��������������������� ����������������������������¾������� �����������������������!�NETSCAPE2.0!� ,��3f���++3+f+�+�+�UU3UfU�U�U���3�f��������3�f��������3�fՙ��� ���3�f������3333f3�3�3�3+3+33+f3+�3+�3+�3U3U33Uf3U� 3U�3U�3�3�33�f3��3��3��3�3�33�f3��3��3��3�3�33�f 3ՙ3��3��3�3�33�f3��3��3��ff3fff�f�f�f+f+3f+ff+�f+�f+�fUfU3fUffU�fU�fU�f�f�3f�ff��f��f��f�f�3f�ff��f��f� �f�f�3f�ffՙf��f��f�f�3f�ff��f��f����3�f���̙��+�+3�+f� +��+̙+��U�U3�Uf�U��U̙U�����3��f�����̙������3��f����

Is there any way to decode above output or other ajax method to get image without using webservice?

0 Answers0