donglian8407 2013-10-20 22: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 05:06
    关注

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

    Thank you for all :)

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部