I am trying to send data from function to ajax call using callback function.
I have function:
function CallAfterLogin(data,callback){
FB.login(function(response) { //---
if (response.status === "connected")
{
LodingAnimate();
FB.api('/me?fields=movies,email', function(mydata) {
console.log(mydata);
if(mydata.email == null)
{
alert("You must allow us to access your email id!");
ResetAnimate();
}else {
alert("hi");
callback(data); // <=== Trigger the callback
}
}); //--
} //if
}); //---
Which I am calling on button click event:
<button type="button" onclick="CallAfterLogin()" ?>Click Me!</button>
I want to send data to ajaxResponse()
function:
function AjaxResponse()
{
document.CallAfterLogin(mydata, function(send) {
var myData = 'connect=1';
$.ajax({
type: "POST",
url: "process_facebook.php",
data: {
connect: 1,
myd: mydata //
}
}).done(function(result) {
$("#fb-root").html(result);
});
});
}
Above code works till callback(data); // <=== Trigger the callback
and then in Firebug I could not see any error or warning. It shows profiler is running
for few seconds and then no activity.
I think there's issue after call to callback(data);
Can someone give me what is the issue here?
I tried to call ajaxResponse()
function on buttonclick event but it makes no action.