Convert from synchronous ajax to promises. Because reasons.