I can't get Json object atribute

Im using JS to do some function in my webpage and i have backend function giving me this JSON

{ "id": 1, "name": "First Like", "description": "Like at least 1 page", "image": "images/badges/FIRST_LIKE"}

So i learned how to get those atributes with jQuery, I can get "name" and "description" but somehow I cant get "image" atribute which I need to add to url to call image href. Can anyone help me? This is my JS function:


              function (data) {
                var name=data.name;
                var description=data.description;
                var image=data.image;

                document.getElementById("name").innerHTML = name.toString();

Its not giving me any error or something. Just wont get the "image" atribute.


For tag image you need to use src attribute:

document.getElementById("image").src = image;

And you don't need to call toString() function, it's already String

See working example:

var data = { "id": 1, "name": "First Like", "description": "Like at least 1 page", "image": "http://cdn.sstatic.net/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a"};

var name=data.name;
var description = data.description;
var image = data.image;

document.getElementById("name").innerHTML = name;
document.getElementById("description").innerHTML = description;
document.getElementById("image").src = image;
<div id="name"></div>
<div id="description"></div>
<image id="image"></image>

Need Your Help

Rotating an image based on key presses

java swing rotation keylistener key-bindings

I was trying to modify an existing code to rotate an image based on key presses. so far i've managed to do the following and I'm stuck. i've made use of Affine transform for the first time. The image

python tsp travelling salesman undirected graph

python graph networkx traveling-salesman

In other posts Networkx was suggested as "my friend". But there doesn't seem to be a ready to use function for a certain solution for the TSP problem.