How to access a variable from outside of Ajax code [duplicate]

I would like to make fileContent variable available outside of $.ajax code.

var fileContent = "";

$.ajax({
method: "POST",
url: "php/somefile.php",
data: {"nazwaProduktu": "nazwa produktu"},
}).done(function( data ) {
        var result = $.parseJSON(data);
        if (result!== null){
            var len = result.length;
                for(var i=0; i<len; i++){
                    fileContent=fileContent+result[i].nazwa+";";
                    fileContent=fileContent+(result[i].komentarz)+"n";
                }
            }
        }
);

console.log(fileContent); //here I see fileContent empty! I need to have it updated by the above code.

Can you please advice how can I do this?