I've got the following code:
$(document).ready(function() {
    var blu = getData();
    console.log(blu); //this shows full the array in the console
    console.log(blu.length); //this gives back 0
});
With the following function getData()
function getData() {
    var arr = [];
    var json;
    $.ajax({
        url: "someurl.com",
        dataType: 'json',
        data: json,
        success: function(json) {
            var x = json.somejson.somenumericvalue //gets the amount of dataentries
            for (i = 0; i <= x - 1; i++) {
                arr.push(json.feeds[i].field1); // fill up array with the values from the json feed
            }
        } //end of success function
    }); //end of ajax
    console.log(arr.length) //shows the correct length of the array
    return arr;
} //end of function getData
Problem is I want to access the values and do methods (like .length) with the array which is filled in the function but it somehow does not work. Anyone can help out? Cheers.
 
     
     
     
    