Problem loading elements into timeline

Hi all,

New to all this, but here goes… (BTW - love the scheduler!!)

I think I could have a timing/technique issue (story of my life!!).

I’m loading the elements (rows) for a timeline view from mySql, with a script (below) in-line. When I call the page, I get no rows showing, but the page works every time on a refresh, so users have to hit F5 to get the data to show.

On 1st load, I get ‘element is not defined’ (see code below), though I AM getting the data back ok (console.log dump show fine).

Is this a timing issue? If so, can anyone better experienced (guess that’s most of you!) suggest a better method?

Here’s the code I’m using to load the rows… - note that I’ve unsuccessfully tried to trigget a page reload if ‘elements’ isn’t defined, but that doesn’t seem to trigger.

I’m not an expert by any stretch of the imagination, but I thought I’d chime in for a little bit of brainstorming.

Off the bat, my initial impression is of the variable “element”. Has that been properly declared prior to you assigning a value to it?

Next, I’d check the sequence of when functions are fired. Try “alert” instead of “console.log”. Maybe the initialization of the scheduler is being fired prior to actually getting the data. I’d also look into the whole window.load vs $(document).ready() argument.

Just my $0.02.

  • jiminee

Hello,
what console.log (data) shows?

Hi,

Sorry for the reply delay - quick vacation in Barcelona took priority :wink:

Console log shows ‘Uncaught ReferenceError: elements is not defined’ prior to showing the ajax data ok.

Hi,
did you check jiminee answer? If the ‘elements’ variable is accessed from somewhere else before it is initialized in the ajax callback - you’ll have the error like you have in console.

Hi,

I’m still struggling here (though I must admit that I’m fumbling in the dark a little due to my inexperience!).

If I define ‘elements’ just before the Ajax call, the console error itself goes away, but the data still doesn’t get into the scheduler before it loads… so instead of my list of elements showing, the scheduler shows only 3 lines, all with ‘undefined’ in the left column. (I’m actually trying to load about 20 elements from MySQL)

What confuses me is that a refresh (and all subsequent refreshes) work just fine. I’t only the initial page load that wont work.

Hope that helps?

Hi,
ajax method is asynchronous. It means that when you initialize the scheduler the ajax callback isn’t called yet (and the elements are not loaded).

If the ‘elements’ can be loaded into scheduler directly, you can call
scheduler.parse(elements) from a callback, instead of using elements as a global variable.