decoupled the js a bit to allow testing for post requests.

Note: I have no idea of js, gotta rewrite that soon ;)