Attempting to get EventsController to work

The error that pops up is bewildering to me at best. I know it has to do
with javascript being ascynchronous but I have no idea how to fix it. If
anybody know what to do, please feel free to edit my solution!
Fixed some issues with EventsController

Also, added more functionality to it. The asynchronous behavior of
javascript means that EventsController will probably need to be
rewritten as all the issues I'm having are due to that. I would fix it
but I don't have a clue how to. If anybody does, feel free to work on
it.