d3.json()无法执行.不断收到错误:400 [英] d3.json() won't execute. keeps getting error: 400

查看:255
本文介绍了d3.json()无法执行.不断收到错误:400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个虚拟JSON值,并试图显示它们,但问题是我不断收到此错误:

I'm creating a dummy JSON value and is trying to show them but the problem is i keep getting this error:

我的代码段如下:

var jsonData = '[{"id":"31370100","machine_name":"GUMACA BRANCH CAM","machine_type":"CAM","operation_start":"05:04:33","operation_end":"09:04:33"}]'

d3.json(jsonData).then((data)=>{
  console.log(data);
});

推荐答案

d3.json将URL作为参数.由于已经有了JSON,您可能只需要JSON.parse(),并且在此实例中无需使用d3.因此您的代码应类似于:

d3.json takes a URL as the parameter. As you have the JSON already, you probably just need JSON.parse(), and there is no need to use d3 in this instance. So your code would look something like:

var jsonData = '[{"id":"31370100","machine_name":"GUMACA BRANCH CAM","machine_type":"CAM","operation_start":"05:04:33","operation_end":"09:04:33"}]'

let data = JSON.parse(jsonData);
console.log(data);

这篇关于d3.json()无法执行.不断收到错误:400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆