JSON binaryData图像

时间:2018-05-21 04:42:01

标签: javascript java json

专栏"图片"在MYSQL中有LONGBLOB数据类型。 JSON将图像解析为BLOB。我想在图像中使用图像src =""

var selectLapbooks = function () {
    var request = new XMLHttpRequest();
    request.open("GET", "SelectLapbook", false);
    request.send();
    if (request.status === 200) {
        var response = request.responseText;
        var lapbooks = JSON.parse(response);
        var element = document.getElementById("lapbooks");
        element.innerHTML = "";
        for (var i = 0; i < lapbooks.length; i++) {
            var img = new Image();
            img.src = window.URL.createObjectURL(new Blob([lapbooks[i].picture]));
            element.innerHTML +=
                "<a href='#'><img class='card-img-top' src='"+img.src+"' alt=''></a>";
        }
    }
};

enter image description here

图片中的数据

enter image description here

0 个答案:

没有答案