Nafis Abdullah Khan
Nafis Abdullah Khan

Reputation: 2390

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. I have used d3.json() to read from a php file which is 'echo'ing some JSON value. This works fine in my PC XAMPP server but not working on a 000webhost free server. Can someone please tell me what could be the problem? I am getting JSON data using The following way .

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

the php file is echo ing the following json array:

[{"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"}]

Upvotes: 0

Views: 2199

Answers (2)

Nafis Abdullah Khan
Nafis Abdullah Khan

Reputation: 2390

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. That was creating problem calling the expected correct JSON string.

Upvotes: 0

Steve
Steve

Reputation: 8640

Doesn't the URL need to be a string?

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

Upvotes: 1

Related Questions