I am trying to write a generic function which will fill any array I pass in with data from the server. The code below does fill the array within the function properly, but when I try to pass in the 'characters' array it won't take it.
Here is the function call:
$(document).ready(function() {
    databaseConnect("loadCharacter.php", characters);
    document.write(characters[0]); //This spits out 'undefined'
});
And here is the function:
function databaseConnect (file, array) {
    if (login == true) {
        $.ajax({
            type: "POST",
            url: file,
            data: {id : identi},
            success: function(data, array) {
                array = data.split('-');
                i = 0;
                while(array[i]) {
                    array[i] = JSON.parse(array[i]);
                    ++i;
                }
            },
        });
    } else {
        document.write("Dude. You're not logged in.");
    }
}
 
    