Changing ajax calls to be easier to handle events