Added validation checks for ajax