Some boilerplate code for ajax login