0

I have some problem. This is my code snippets :

FB.api('/me', function(me){
  if (me.id) {
  alert(me.id);
  //alert(me.email);
  var fbmail = me.email;
  alert(fbmail);
  document.write('<input id="mail" type="hidden" value="'+fbmail+'">');                    
  var retro = document.getElementById('mail').value;
  alert(retro);                    
})

My problem is that there is no alert(retro); :( Can you tell me what's wrong???

1
  • Sorry about my ignorance, but what is FB? Commented Aug 12, 2012 at 17:10

1 Answer 1

2

document.write can only be used while the page is loading.

Calling it in an async callback will erase the current page, so getElementById will return null.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanx for all of your answer. I'm always searching for a solution.

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.