Fixed the async issue by making the AJAX request syncronus (duh, I'm an idiot.)