tried to tie the ajax request to a function

forces the ajax to be synchronous in a way, doesn't work yet