Definitions of success and error handling

need to fix $.ajax() error