I have the following method in JavaScript:

```
function getData(){
    var result;

    $.getJSON("app/data/ptl", function (data) {
        if (data == null) {
            return false;
        }

        var x_data = new Array();
        var y_data = new Array();

        $.each(data, function(index, value) {
            x_data.push(index);
            y_data.push(value);
        });

        result = [months_data,value_data];

    });

    alert('');
    return result;
}

```

When this method is called, the exact data is retrieved. However when I remove `alert('')` the data is not received. Does anyone know a reasonable explanation for such problem?