Advertisement
Guest User

Untitled

a guest
Dec 5th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.64 KB | None | 0 0
  1.  
  2. //ROUTES DON'T FORGET TO DO RAKE ROUTES BEFORE RELOADING!
  3.     post 'participants/GetParticipant' => 'participants#GetParticipant'
  4.  
  5. //CONTROLLER
  6. //PUT THAT LINE JUST AFTER YOUR BEFORE ACTION
  7.     skip_before_action :verify_authenticity_token,only: [:GetParticipant]
  8. //THEN DO YOUR FUNCTION
  9.   def GetParticipant
  10.     participant = Participant.last
  11.     puts participant.to_s
  12.     render :json => {data:participant}
  13.   end
  14.  
  15. //JAVASCRIPT OF YOUR GAME
  16.     function GetParticipant(){
  17.        $.ajax({
  18.         url: "/participants/GetParticipant",
  19.         type: 'post',
  20.         complete: function(data){
  21.           console.log(data);
  22.         }
  23.       });
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement