My current challenge involves creating a login using Facebook. The console indicates that the requested data (email, first_name, etc.) is being retrieved successfully, but for some reason, the AJAX request keeps sending null data to the PHP method.
Below is the AJAX code being used:
function saveUserData() {
FB.api('/me?fields=id,first_name,last_name,email', function(response){
$.ajax({
url: '<?php echo base_url();?>Auth/fb_auth',
data: {response: JSON.stringify(response)},
type: 'POST',
dataType: 'json',
success: function (data) {
if(data['state'] == 'ok'){
window.location.href ="<?php echo base_url(); ?>";
}
}
});
});
}
Here's how I am attempting to retrieve the data in the PHP method:
$response = json_decode($this->input->post('response'), true);