javascript - D3.js JSON parse error -


while parsing inline json object d3.json(obj, function(error, root), working when i'm running locally, when run on tomcat server i'm getting xmlhttpparse error. searched on internet. answer found cors. there no clarity how achieve this. please me?

var obj = {  "name": "vis",  "children": [   {    "name": "votes",    "children": [     {"name": "200", "size": 200,"url":"1"},     {"name": "500", "size": 500,"url":"2"},     {"name": "300", "size": 300,"url":"3"},     {"name": "400", "size": 400,"url":"4"}    ]   },     {    "name": "reputation",     "children": [     {"name": "200", "size": 200},     {"name": "500", "size": 500},     {"name": "300", "size": 300},     {"name": "400", "size": 400}    ]   },   {    "name": "accepted answer",    "children": [         {      "name": "encoder",      "children": [       {"name": "accepted answer", "size": 500}      ]     }    ]   }  ] }; d3.json(obj, function(error, root) {     alert('error '+error);     alert('root: '+root);   if (error) return console.log(error); } 

you misunderstanding d3.json used for. d3.json makes actual ajax request (hence why in documentation names chapter requests) literally trying fetch obj can't because doesn't need to. if want use d3.json, can move json object own file , reference doing d3.json(data.json, function(err, root)).

the result d3.json return literally object have declared. can assign variable name root.

related question: d3 js - loading json without http get


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -