Handling server side of AJAX in the controller