0

I get such javascript:

  FB.api('/me', function(response) {
      var name = response.name;
          first_name = response.first_name;
      alert("Name: "+ name + "\nFirst name: "+ first_name);}

How I could get value of name and first_name to rails controller? I use Rails 3.2.

1 Answer 1

1

Place the value of the javascript array in a request parameter, either via ajax or by setting the value of a form input. I'm going to use jQuery in my examples:

Option 1 (ajax):

$.post('/users/some_action', {"name" : name, "first_name", first_name})

Option 2 (setting a form):

$('#name').val(name)
$('#first_name').val(first_name)

In your controller:

name = params[:name]
first_name = params[:first_name]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.