0
       FB.api('/me', function(userInfo) {
            console.log(userInfo.email);
            var emailid = userInfo.email;
            console.log(emailid);


            })

            $.ajax({
             url: 'index.php?r=tryon/saveemailid', 
             type:'post',
             data:{'saveemail':emailid},
             success : function(data){
              alert("success!");
             }
            });
3
Contributors
6
Replies
21
Views
3 Years
Discussion Span
Last Post by nileshbhanu
0

i have store user email in one variable and want to pass it ajax data ?

1

Hi,
emailid is declared in FB.api, in this case emailid isn't visible for $.ajax({....})
Declare emailid before FB.api and just set value for this variable in FB.api

var emailid = "";
 FB.api('/me', function(userInfo) {
    console.log(userInfo.email);
    emailid = userInfo.email;
    console.log(emailid);
})
$.ajax({
    url: 'index.php?r=tryon/saveemailid',
    type:'post',
    data:{'saveemail':emailid},
    success : function(data){
        alert("success!");
    }
});
0

Just to add, research 'scope of variables' for more info.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.