0

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"}]
3
  • What does "not working" mean? Any JS errors? Can you confirm the browser is making the call and if so, what is the response? Commented May 4, 2012 at 19:01
  • I am getting No JS errors. I don't know how to check response but I used alert before and after the call like alert("bbb"); d3.json(d3/section1/section1.php, function(data) { alert("aaa");.... and the first alert is apearing but the second one is not. That means the response is not coming. Commented May 5, 2012 at 5:40
  • Are you using any JS debugging tools like Firebug? They show you JS errors in the console log and have a way to look at the response from the server. Commented May 5, 2012 at 15:59

2 Answers 2

1

Doesn't the URL need to be a string?

d3.json("d3/section1/section1.php", function(data) {...
Sign up to request clarification or add additional context in comments.

3 Comments

Can you please explain what do you mean by string? The same way from a json file it works both my pc and online. Like: d3.json("d3/section1/section1.json", function(data) {...
If you mean query string to send data by url, then no, it doesn't reqire. the php is not using any $_GET or $_POST variable. it's getting data from a perticular mysql table and making it echo as the above json format.
All I was pointing out was that in your example above, you did not have quotes around the file you are trying to access. You need quotes around d3/section1/section1.php, which you don't have in your example.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.