I have run into a problem with a named function in Javascript.
I have this reload function
SN.Reload = function(settings) {
var _timer = null;
var $grid = null;
var init = function () {
$grid = $(settings.wrapperSelector);
if (_timer > 0 || _timer != null)
_timer = settings.timer;
else
_timer = 600000;
window.setInterval(function () {
LoadData();
}, _timer);
};
var LoadData = function () {
$.ajax({
url: '/data.json',
type: 'GET',
dataType: 'json',
cache: false,
success: UpdateData,
error: DataErrorHandler
});
};
}
In the normal state this will run LoadData function at X minutes - this works as intended.
I now have another named function
SN.CreateJsonFromDate = function (settings) {
....
var SuccessLoad = function () {
_dateLoader.hide();
_wrapper.slideUp();
}
}
Is it possible to use LoadData from SN.Reload Inside the SuccessLoad function in SN.CreateJsonFromDate ?
The LoadData function call UpdateData on success an updates the HTML from the json data and I want to call this function again in SN.CreateJsonFromDate as this will generate a new json file.
SN.Reloadis to declare some variables (some of which are functions) and then do nothing with them and abandon them?LoadDatais only accessible inside the scope ofSN.Reloadand, as the code is written, is not accessible outside of it.