Search notes:

D3.js - Reading data

JSON

A simple example that tries to demonstrate how a JSON document can be read with D3.js.
<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>Reading JSON with D3.js</title>

</head>
<body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.6.1/d3.min.js"></script>

<script>

d3.json('data.json').
   then(function(jsn){
      alert("txt = " + jsn.txt + "\n" + "num = " + jsn.num);
   }).
   catch(function(err) {
      alert("Error: " + err);
   });

</script>

</body>
</html>
Github repository about-d3.js, path: /data/json.html
This is the document:
{
  "num":  42,
  "txt": "Hello world"
}
Github repository about-d3.js, path: /data/data.json
In order to test this example on a local computer, a CORS capable webserver must be started (for example with Python).

See also

D3.js

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1741107620, '18.118.7.166', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/web/libraries/D3_js/data/index(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78