Zeldus

getData

function
getData()

Option name Type Description
name Object the name of the data source
path Object the URL of the data source
callback Object a function that it called once the data has been loaded

Get the JSON data

function getData(name, path, callback){
	    var xmlhttp = new XMLHttpRequest();
	    xmlhttp.overrideMimeType('application/json');  
	    xmlhttp.onreadystatechange = function() {
	    	//check if request was successful
	        if (xmlhttp.readyState === 4 && (xmlhttp.status === 200 || xmlhttp.status === 0)) {
	        	callback(name, JSON.parse(xmlhttp.responseText));
	        }
	    };
	    xmlhttp.open('GET', path, true);
	    xmlhttp.send();
	}

DSLoader

function
DSLoader()

Option name Type Description
name Object the name of the data source
path Object the URL of the data source

Data Source Loader. Retrieves JSON data from a path

function DSLoader(name, path) {
		var self = this;

get

method
self.get()

Option name Type Description
callback Object a function that it called once the data has been loaded

Get the JSON data

self.get = function(callback){ 
			getData(name, path, callback);
		};
	}
	return DSLoader;
});