[英]getting json data with d3.json() from php not working
I am using Javascript d3.js library to draw some charts which are getting data from a MySQL database using php. 我正在使用Javascript d3.js库绘制一些图表,这些图表正在使用php从MySQL数据库获取数据。 I have used d3.json() to read from a php file which is 'echo'ing some JSON value.
我已经使用d3.json()从php文件中读取,该文件正在“回显”一些JSON值。 This works fine in my PC XAMPP server but not working on a 000webhost free server.
这在我的PC XAMPP服务器上工作正常,但在000webhost空闲服务器上不起作用。 Can someone please tell me what could be the problem?
有人可以告诉我可能是什么问题吗? I am getting JSON data using The following way .
我正在使用以下方式获取JSON数据。
d3.json(d3/section1/section1.php, function(data) {...
the php file is echo ing the following json array: 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"}]
URL不需要是字符串吗?
d3.json("d3/section1/section1.php", function(data) {...
The problem is solved. 问题已经解决了。 The online server was a free server which is embedding a javascript enclosed by html tags at the end of each page.
在线服务器是一个免费服务器,它在每个页面的末尾嵌入了一个用html标记括起来的javascript。 That was creating problem calling the expected correct JSON string.
这在调用预期的正确JSON字符串时造成了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.