By default, all ajax requests are sent asynchronously. The getDocOrganization() function returns before the AJAX call returns.
As a workaround, you could make the AJAX call synchronous with the async: false
option.
Like this:
$.ajax({
async: false,
url: url + "/_api/web/lists('3224B8D6-EE69-442C-818B-2BD2224C481C')/items?$filter=Title eq '" + encodeURIComponent(docOrg) + "'",