How to get variable from javascript to rails -
i such javascript:
fb.api('/me', function(response) { var name = response.name; first_name = response.first_name; alert("name: "+ name + "\nfirst name: "+ first_name);}
how value of name
, first_name
rails controller? use rails 3.2.
place value of javascript array in request parameter, either via ajax or setting value of form input. i'm going use jquery in examples:
option 1 (ajax):
$.post('/users/some_action', {"name" : name, "first_name", first_name})
option 2 (setting form):
$('#name').val(name) $('#first_name').val(first_name)
in controller:
name = params[:name] first_name = params[:first_name]
Comments
Post a Comment