0

我正在使用 Javascript d3.js 库来绘制一些图表,这些图表使用 php 从 MySQL 数据库中获取数据。我已经使用 d3.json() 从一个“回显”一些 JSON 值的 php 文件中读取。这在我的 PC XAMPP 服务器中运行良好,但在 000webhost 免费服务器上无法运行。有人可以告诉我可能是什么问题吗?我正在使用以下方式获取 JSON 数据。

d3.json(d3/section1/section1.php, function(data) {...

php 文件正在回显以下 json 数组:

[{"spark":[1,0.2,0.3,0.5,0.1,0.4,0.8,0.3,0.2,0.7,0.6,0.9],"mes":[88],"mark":[90],"info":"Network"},{"spark":[0.1,0.3,0.2,0.5,0.1,0.4,0.2,0.3,0.2,0.7,0.6,0.5],"mes":[87],"mark":[85],"info":"ERP"},{"spark":[1,0.2,0.3,0.5,0.1,0.4,0.8,0.3,0.2,0.7,0.6,0.9],"mes":[90],"mark":[100],"info":"Data Warehouse"},{"spark":[1,0.2,0.3,0.5,0.1,0.4,0.8,0.3,0.2,0.7,0.6,0.9],"mes":[95],"mark":[90],"info":"Web Site"},{"spark":[1,0.2,0.3,0.5,0.1,0.4,0.8,0.3,0.2,0.7,0.6,0.9],"mes":[98],"mark":[88],"info":"Email"},{"spark":[1,0.2,0.3,0.5,0.1,0.4,0.8,0.3,0.2,0.7,0.6,0.9],"mes":[90],"mark":[96],"info":"HR"},{"spark":[1,0.2,0.3,0.5,0.1,0.4,0.8,0.3,0.2,0.7,0.6,0.9],"mes":[100],"mark":[92],"info":"Problem Tracking"}]
4

2 回答 2

1

URL不需要是字符串吗?

d3.json("d3/section1/section1.php", function(data) {...
于 2012-05-04T19:00:48.277 回答
0

问题已经解决了。在线服务器是一个免费服务器,它在每个页面的末尾嵌入了一个由 html 标记包围的 javascript。那是在调用预期的正确 JSON 字符串时产生问题。

于 2012-05-05T17:57:51.863 回答