refactor ajax handling

the ajax submission was thrown in as a proof-of-concept, but it was just
sloppy jQuery spaghetti. it's a bit cleaner right now but it's clear
than I need to establish a javascript file convention in the future.