Tidy up js

Switch everything to .ajax for better error handling