I'm trying to update an h3
with the id data
using Ajax. The Ajax uses a get request to retrive data from an API, but for some reason the html is not being updated.
This is what the json data looks like {ticker: "TEST", Price: 7876}
I tried to change $('#data').text(data[0].data[]);
to $('#data').text(data[ticker].data[]);
, for example, but it didn't work either.
I added a console.log(data[0])
to debug it, and the data normally appears in my console.
function doPoll(){
$.get('http://localhost:8000/tst/', function(data) {
console.log(data[0]);
$('#data').text(data[0].data);
setTimeout(doPoll, 1000);
});
}
doPoll();
And this is the html part to be updated:
<h3 id="data"></h3>
Basically instead of that h3 there should be my data updated every tot seconds, but at the actual moment nothing appears.