Reputation: 309
Im making a Login whit facebook. using the javascript sdk im geting the response (i guess is JSON), and i want to send this response to a php file to check if the user is in the database or not.
so heres what i got so far. this is the function i call when the user is loged into facebook.
function testing(){
FB.api('/me', function(response) {
response = JSON.stringify(response);
//call another function, sending the data recived
ajaxlog(response);
});
}
and here is the ajaxlog function
function ajaxlog(facedatos){
$.ajax({
type: "POST",
url: "facebook-ajax-login.php",
dataType: "json",
data: facedatos,
success: function(response){
//the php brings the conect response true or false
if(response.conect==true){
$("#exist").html(response.data);
}else{
}
},
beforeSend: function(){
$("#exist").html("<img class='img-responsive ajax-l' style='width:40px;padding-top:10px;margin-right:10px;' src='images/ajax-loader.gif' />")
}
});//<!--ajax-->
im doing alerts and the facebook data comes with no problem. i think the issue is how i send the data by post, im not reciving the data in the php
Upvotes: 2
Views: 262
Reputation: 309
I find the issue by myself, the problem is that i was sending the post request whitout a name. in the ajax function changed
data: facedatos,
for
data:{
face: facedatos
}
and in the php recived the data as $_POST["face"];
Upvotes: 2