I'm having problems with JavaScript and especially with a variable:
var totalrec = {};
$http.get('url').
success(function(data, status, headers, config) {
totalrec = data;
//here it all works
console.log(data);
}).
error(function(data, status, headers, config) {
.....
});
//here it prints an empty object
console.log(totalrec);
I receive a JSON string from an external server. When I print it to the console.log in the success function it works. But I need arguments from the JSON string outside the function. If I print it to the console.log outside the function it prints an empty object.. Who can help me?