1

i am new in D3 JS. I would like to load json data from D3 js. Here, I am not sure if json is loaded. Here, non of message is appear. I want show html and json data ,

mydata.json


   [
    {"name":"Hira","age":35},
    {"name":"Basu","age":26},
    {"name":"Mukhia","age":30}
]

HTML

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<script>
d3.json("./mydata.json", function(data) {
  console.log(data);
});
</script>
</body>
</html> 

Hope if you guys can give some hints.

  • Possible duplicate of [Code within d3.json() callback is not executed](https://stackoverflow.com/questions/49768165/code-within-d3-json-callback-is-not-executed) – altocumulus Nov 29 '18 at 08:01
  • Yes, call back is not executed due to the version of d3js. I was trying with old version of D3JS . Now D3JS will use call back function on then function – Hira Kumar Maharjan Nov 30 '18 at 12:08

1 Answers1

1

here, I got a solution.

d3.json("./mydata.json").then(function(data){
    console.log(data);
});

In new version we have to specify then function . In then function we have to make call back function.