- 18.2k
- 5
- 58
- 68
I don't know how exactly you plan to use config, but you certainly need it to be within the same scope in order to access eventdata. I would say get rid of that altogether, and just add it as a property of the object in the ajax callback (shown in code below).
The difficulty here is that you are stuck waiting on the AJAX callback to fire before you can use config in your scripts; this is why ajax is designed to be used with callbacks executed after a particular event rather than linearly; I would advise you to use config only within that success callback, or add a check to see if getJSON has finished executing.
$(function() {
var config = {
width: "100%",
height: "100%",
//source: 'js/timeline/test.json',
//start_at_end: true, //OPTIONAL
//hash_bookmark: true, //OPTIONAL
css: 'js/timeline/compiled/css/timeline.css',
js: 'js/timeline/compiled/js/timeline-min.js'
};
$.getJSON('http://www.mysite.com/json.php', function(data) {
jsonObject = eval(data);
config.source = jsonObject.tlall;
});
}); //END ON LOAD
$(function() {
var config = {
width: "100%",
height: "100%",
//source: 'js/timeline/test.json',
//start_at_end: true, //OPTIONAL
//hash_bookmark: true, //OPTIONAL
css: 'js/timeline/compiled/css/timeline.css',
js: 'js/timeline/compiled/js/timeline-min.js'
};
$.getJSON('http://www.mysite.com/json.php', function(data) {
jsonObject = eval(data);
config.source = jsonObject.tlall;
});
}); //END ON LOAD
I don't know how exactly you plan to use config, but you certainly need it to be within the same scope in order to access eventdata. I would say get rid of that altogether, and just add it as a property of the object in the ajax callback (shown in code below).
The difficulty here is that you are stuck waiting on the AJAX callback to fire before you can use config in your scripts; this is why ajax is designed to be used with callbacks executed after a particular event rather than linearly; I would advise you to use config only within that success callback, or add a check to see if getJSON has finished executing.
$(function() {
var config = {
width: "100%",
height: "100%",
css: 'js/timeline/compiled/css/timeline.css',
js: 'js/timeline/compiled/js/timeline-min.js'
};
$.getJSON('http://www.mysite.com/json.php', function(data) {
jsonObject = eval(data);
config.source = jsonObject.tlall;
});
}); //END ON LOAD
$(function() {
var config = {
width: "100%",
height: "100%",
//source: 'js/timeline/test.json',
//start_at_end: true, //OPTIONAL
//hash_bookmark: true, //OPTIONAL
css: 'js/timeline/compiled/css/timeline.css',
js: 'js/timeline/compiled/js/timeline-min.js'
};
$.getJSON('http://www.mysite.com/json.php', function(data) {
jsonObject = eval(data);
config.source = jsonObject.tlall;
});
}); //END ON LOAD