Move respond later javascript code to separate file
Use try instead of respond_to and public_send

Thanks @galkon