Convert from synchronous ajax to promises. Because reasons.

Here's an example of how you can use [promises](https://www.promisejs.org) to do this. I provided some examples because promises are awesome and everyone should use them for asynchronous stuff. :smiley: 

Also if you plan to mess around much in JavaScript, I highly highly recommend checking out [CoffeeScript](http://coffeescript.org). It kind of ruby-fies JavaScript somewhat and makes developing in it faster. At least after the initial little hurdle.