refactor ajax spinner code
cleanup js code to reduce cohesion between different modules