Loading the Data from JSON

Hi All,

I have got a question which involves loading a json string which was returned from my PHP Class.

I have the json string and I tried performing
scheduler.parse( [ {start_date:"2011-12-01 09:00",end_date:"2011-01-12 10:00",text:"test"} ], 'json' );

I have also tried:
scheduler.load( [ {start_date:"2011-12-01 09:00",end_date:"2011-01-12 10:00",text:"test"} ], 'json' );
However, I cannot seem to get any of it working. What am I doing wrong?

By the way I am running this within the init() function.

Thanks in advance!

Sorry, I forgot to mention that the problem is that nothing is showing up for that event. I have checked, as far as I can tell, everything.

Thanks!

Hello,

Try adding following option before scheduler.init call:

scheduler.config.xml_date="%Y-%m-%d %H:%i";

Same loading is used in the scheduler\samples\06_timeline\02_lines.html sample.

Kind regards,
Ilya

That worked a charm, but if I am retrieving data back from an AJAX request how would I pass the load() or parse() function the responseText (which would be a json encoded string).

Any ideas?

[code] function init() {

    scheduler.config.multi_day = true;
    scheduler.config.xml_date="%Y-%m-%d %H:%i";
    scheduler.init('scheduler_here',new Date(2011,0,1),"month");
    
    if( window.XMLHttpRequest ){
        var xmlHttp = new XMLHttpRequest();
    } else {
        var xmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
    }
    
    
    xmlHttp.open('POST', 'test.php', false);
    xmlHttp.send();
    
    var data = xmlHttp.responseText ;
    
    console.log( data );
    scheduler.load()
            
    scheduler.parse( data, 'json' ); 
}
[/code]

a) you can just use

scheduler.load(“test.php”, “json”);

which will load json data from remote url in the scheduler

b) if you still want to use custom loading, it can be loaded as

var data = xmlHttp.responseText ;
scheduler.parse(data, “json”);

I have got it working now thanks.

Although I tried retrieving the responseText and assigining it to a variable and passing that variable through the function but it didn’t work.

Now I have chosen to perform the functions through XML instead of JSON. It just took a bit more parsing first to get it all from the database.