display image as response to jQuery ajax request
<p>I was trying to display image as response to jQuery ajax request:</p>

<blockquote>
  <p>php code:</p>
</blockquote>

<pre><code>    &lt;div id="r_part"&gt;
    &lt;img src="reports.php" alt="Report" /&gt;
    &lt;/div&gt;
</code></pre>

<blockquote>
  <p>jQuery code:</p>
</blockquote>

<pre><code>    $.ajax({
        type: "POST",
        datatype: "html",
        url: "reports.php",
        data: ({post_year: selected_year}),
        success: function(response){
            $("#r_part").html("&lt;img src=" + base64encode(response) +" /&gt;");
        },
        error: function(){
            $("#r_part").html('Oops! Something wrong ...');
            }
    }); 
</code></pre>

<p>The php part works fine. But, the $.ajax part is not working for me! It provides an output like below:</p>

<p><a href="https://i.stack.imgur.com/wl56V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wl56V.png" alt="enter image description here"></a></p>

<p>Whats wrong with what I'm doing !!! Any help is highly appreciated...</p>

<p>Saiful</p>