donglian8407 2013-10-21 06:49
浏览 240
已采纳

获取图像src作为ajax响应

I need to set image src from ajax response,

I'm trying to get it from ajax but the response is coming like

��Y���.��L�-m1��s�%��vȪ��b<��a�����5�~$����흒6��G��H#;F9`p+��mޝ�"��t�n}FVɪ_�qd��1(��d���,���,p1q�H�D�՞�a����46V� �or9i��Y�X�OsV���{���s�K5��<����\�(��i��� etc..

this.

it's actually image/jpeg which is created by php file. anyone please help me to convert this to proper image source.

my ajax code is

$.ajax({
    method : "GET",
    url : "xxx/yyy/file.php?rand=rand()'; ?>",
    success : function(data)
    {
        $('#image_here').html('<img src="data:image/jpeg;base64,'+data+'">');
    }
});

thank you in advance.

  • 写回答

2条回答 默认 最新

  • dounieyan2036 2013-10-23 13:06
    关注

    I found the solution. I just want to do base64 encoding on image before sending it.

    Thank you for all :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?