I'm developing a graph and I need to change the attribute of a div tag. I don't have access to the whole code, so I'm stuck with using JS, no PHP (I guess I don't need that anyway).
I have the following div:
<div data-serie-data="[4.0,4.0,3.0,4.0,3.0]" id="chartContainer">
I want to replace the data-serie-data with what I retrieve from the following JS function:
$.getJSON('*url*', function(data) {
document.write(data.data);
});
The result from this is:
[5.0,2.0,6.0,1.0,4.0]
How do I replace the current data with this result?
I've tried doing it like this:
$.getJSON('*url*', function(data) {
document.getElementById("chartContainer").setAttribute("data-serie-data", data.data);
});
But this doesn't change the value. I've also tried setting other attributes but that does nothing aswell.
What am I doing wrong?