updated ajax controller for form validation