JSON Error in the Starters Tutorial

Hi there,

I am working my way through the Tutorials of Gantt on docs.dhtmlx.com/gantt/desktop__how_to_start.html. But I can not bring it to work :frowning: .

After Step 6, when I try to fill some Data into the MySQL Database, Firebug gives me the Error
“SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
file:///S:/DHTMLX/Gantt/codebase/dhtmlxgantt.js
Line 4157”

For the HTML code, i have taken the 04_connector_json.html example, just adjusted the folders.

[code]

DB loading html, body{ height:100%; padding:0px; margin:0px; overflow: hidden;}
gantt.config.xml_date = "%Y-%m-%d %H:%i:%s" gantt.init("gantt_here"); gantt.load("data.php");
    var dp = new dataProcessor("samples/common/connector.php");
    dp.init(gantt);
</script>
[/code]

In the data.php I have pasted the code from Step 6, so it should be ready to go.

[code]<?php
include (‘codebase/connector/gantt_connector.php’);

$res=mysql_connect(“localhost”,“root”,“”);
mysql_select_db(“gantt”);

$gantt = new JSONGanttConnector($res);
$gantt->render_links(“gantt_links”,“id”,“source,target,type”);
$gantt->render_table(
“gantt_tasks”,
“id”,
“start_date,duration,text,progress,sortorder,parent”
);
?>[/code]

In the MySQL Database, I have reconstructed the data from Step 4.
Table gantt_links:

Table gantt_tasks:


I would appreciate any help on this problem.

Greetings,
Thomas

Hello,
make sure the page is opened from a web server. When the html page is browsed as a file (by double clicking on html file), ajax won’t work and php won’t run

Also, the common route to resolve data loading problems is the next

a) try to load the data.php directly in the browser, if you have some problems with path or db connection it will show an error details instead of the data

b) if above doesn’t reveal anything, try to add in the php code

$gantt = new JSONGanttConnector($res); $gantt->enable_log("log.txt"); //add this line

and check the content of the log file

Woops, getting the Webserver up first is REALLY a good idea… :blush:

Shame on me for forgetting the most basic things, but thanks for the help.