ajax获取图片

<img  id="contents2_img" alt="" src="images/hope.png" style="width: 100%; height:100%;border: none;">

 

<script>
    var image = '';
    var cate = 10;
    $(document).ready(function () {
        $.ajax(
            {
                type: "GET",
                url: baseURL + 'api/articles/getArticlesList?catecode=10',
                data: {},
                success: function (data) {
                    if (data.code == 0 && data.articlesList.length>0) {
                        var $data = data.articlesList[0].content;
                        console.log($data)
                        $("#contents2_img").attr('src', $data);
//                        document.getElementById('contents2_img').src=$data;

                    }
                }
            });
    })
</script>

 

posted @ 2018-01-11 13:49  huahua_0825  阅读(671)  评论(0编辑  收藏  举报