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.

2
  • Possible duplicate of Code within d3.json() callback is not executed Commented Nov 29, 2018 at 8: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 Commented Nov 30, 2018 at 12:08

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.