return $.ajax instead of returning the data

Allows for hooking into the ajax promise instead of just returning the data itself. Also cleaned up some of the logic so that ajax request was not in an each loop.