Wrap ajax call inside promise

So this is based on @stefanpenner's suggestion as a better way to improve performance than #57, however I don't really see much performance difference with this approach. It does seem to make the code cleaner though, so I'm filing this pull request anyway.