Hello I have a jquery ajax call that returns json data from an api.
I turned that json into a variable and want to use it in d3.json.
It isnt taking the variable name, I think because its expecting a url instead of a variable name.
Here is the code:
jQuery.ajax({
type: "GET",
url: myurl.com,
success: function(effects)
{
var dataArray = effects;
d3.json(dataArray, function (data) { //error here
console.log(data);
});
}
});
Those of you good with d3, can you help me get the json data into the d3.json function?
Thanks
d3.json()is not just for parsing; it will request the JSON resource and parse it, whereasjQuery.ajax()only requests the resource without parsing it. When usingjQuery.ajax()you need to use the nativeJSON.parse()to parse the JSON string, notd3.json()**!d3.jsonalready does the AJAX request for you, so I'd just use that if possible.