$(document).ready(function() {
var charts;
$.post(location.href, {}, function(data){
charts = data;
return charts;
}, 'json');
console.log(charts);
});
$.post(location.href, {}, function(data){
charts = data;
return charts;
}, 'json');
console.log(charts);
ответ еще может не прийти. И получаете undefined.$.post(location.href, {}, function(data){
console.log(data)
doSomething(data)
}, 'json');