I created a function that takes the values of a JSON and (should send those values to variables inside the function) so I could use these variables in the continuation of the function. The problem is that when I run the function it does not return the values ... if I take the internal code from it and run it on the DOM it works but calling it does not ... Does anyone give me a help please?
//get connection info's to access the system
function connection(){
//vars
var servername;
var database;
var username;
var password;
//get JSON values
$.getJSON('./data/configuration.json',function(data){
servername = data.servername;
database = data.database;
username = data.username;
password = data.password;
});
console.log(servername);
console.log(database);
console.log(username);
console.log(password);
}