Ajax handling and attaching to the view