2 votes

Call image with data tables

I need to be able to insert the image field of a json response from marvel api. I am using the jquery data tables plugin.

Image url:

 imagen_personaje.attr('src', personaje.thumbnail.path + '/landscape_small.' + personaje.thumbnail.extension)

DataTables:

   $('#tabla').dataTable({
    ajax: {
        cache: true,
        url: `https://gateway.marvel.com/v1/public/characters?&ts=${ts}&apikey=${publicKey}&hash=${hash}`,
        dataSrc: 'data.results'
    },
    columns: [{
        "data": "id"
    }, {
        "data": "ImagePath",
        "render": function (data) {
        return '<img src="' + thumbnail.path +'/>';
        }
    }, {
        "data": "name"
    }, {
        "data": "description"
    }]
});

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X