Use promise callbacks on ajax requests, shorten code