Hi LDM,

What was the output of your php file?

It should ONLY be

{
  'wiki-url':"http://simile.mit.edu/shelf/";,
  'wiki-section':"Simile JFK Timeline",
  'dateTimeFormat':'Gregorian',
  'events':[
    {
       'start':"Sat May 20 1961 00:00:00 GMT-0600",
       'title':"'Bay of Pigs' Invasion",
       'durationEvent':false
     },{
       'start':"Wed May 01 1963 00:00:00 GMT-0600",
       'end':"Sat Jun 01 1963 00:00:00 GMT-0600",
       'durationEvent':true,
       'title':"Oswald moves to New Orleans",
       'description':"Oswald moves to New Orleans, and finds employment at the
William B. Riley Coffee Company. <i>ref. Treachery in Dallas, p 320</i>"
     },{
      ...
     }]
}
NOTHING else.
No <html> etc.

You can find out what the response of your php file is by loading it into a 
browser.  Or by using firebug when loading the Timeline html file.

Note:
You should change the response type of your php program to be application/json
Put the following as the VERY first line in your php file

header("Content-Type: application/json; charset=utf-8");

For example:

<?php
header("Content-Type: application/json; charset=utf-8");
... rest of your php
?>

Do NOT do this
<html>
<body>
<?php
header("Content-Type: application/json; charset=utf-8");
... rest of your php
?>

See http://us3.php.net/header

Your comment "I don't think the php file is being parsed as a php file when 
loaded through the tl.loadJSON function"
Why do you think this? When the Ajax function calls your server, it will run 
the php file (via the php interpreter) and then send the results to the client 
program. My guesses:
1) A problem with the php file is causing it to not work or
2) The result from the php program are not valid json.

Regards,

Larry



________________________________
From: JadedAngel <[email protected]>
To: SIMILE Widgets <[email protected]>
Sent: Wednesday, April 1, 2009 6:46:13 PM
Subject: Re: How to load timeline data that doesn't come from a file?


Well.....I tried this (with a simple test file) and I don't think the
php file is being parsed as a php file when loaded through the
tl.loadJSON function. Dang. That would have been too easy, lol.

So, I'm still looking to find out how to load the data into some var,
essentially bypassing the tl.loadJSON function.



On Apr 1, 3:18 pm, John Callahan <[email protected]> wrote:
> Could you do something like...
>
> tl.loadJSON("myfile.php?"+ (new Date().getTime()), function(json, url) {
> eventSource.loadJSON(json, url);
>
> ...and myfile.php file simply performs the query and returns the array
> of data...
>
> myfile.php would be something like...
> <?php
> ...
> $qresult = mysql_query($query) or die(mysql_error());
> ...
> if (mysql_num_rows($qresult) > 0) {
> $qstring = ...
> while($row = mysql_fetch_array($qresult)){
>     $qstring .=  ...}
>
> echo $qstring;
> ?>
>
> I don't think you need the new Date() extension to the file call here as
> the php file will be executed each time and not stored in cache
>
> - John
>
> **************************************************
> John Callahan
> Geospatial Application Developer
> Delaware Geological Survey, University of Delaware
> 227 Academy St, Newark DE 19716-7501
> Tel: (302) 831-3584  
> Email: [email protected]http://www.dgs.udel.edu
> **************************************************
>
> JadedAngel wrote:
> > My apologies in advance if I'm posting this in the wrong place. If
> > that's the case, please let me know where this question should be
> > asked.
>
> > I'm developing an application that will read Timeline data from a
> > mySQL database using PHP. At the moment (just to get things working)
> > we're reading the data and then writing it to a temporary file (called
> > 'myfile.js' in this example), with the data in JSON format.
>
> > The current way Timeline loads the data is through this function:
>
> >  tl.loadJSON("./data/myfile.js?"+ (new Date().getTime()), function
> > (json, url) {
> >    eventSource.loadJSON(json, url);
>
> > Rather than write to a file and then read it back in, we'd like to
> > read from the database then and insert it directly into a javascript
> > variable, something like:
>
> > <?php
> > // php code for reading data from the database goes here,
> > // and the data gets returned as the PHP var "$timeline_data"
> > ?>
> > <script type='text/javascript'>
>
> > // printed via PHP, the data is stuffed into the javascript var 'foo'
> > var foo = <?php echo $timeline_data;  ?>;
>
> > The problem is that I have no idea what javascript variable the data
> > in 'myfile.js' is supposed to end up in. What would I replace the
> > current data file loading lines with to insert the returned data
> > directly into a javascript var so that TimeLine can use it?
>
> > In other words, what Javascript variable does the data loaded through
> > these two lines end up in:
>
> >  tl.loadJSON("./data/myfile.js?"+ (new Date().getTime()), function
> > (json, url) {
> >    eventSource.loadJSON(json, url);
>
> > I thank you in advance for any help you may be able to offer.
>
> > LDM
> > [email protected]
> > (Timeline n00b)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to