Use promise objects to handle AJAX requests a little better.