i have a success function that has some data stored inside it:
function(receiverUserIds) {
console.log("IDS : " + receiverUserIds.request_ids);
}
this will log: IDS :123123213, 4645646654, 7897987989, ….
what i want to do is grab all those id’s and store them in the database.
one way i was thinking to do it is by using ajax:
function(receiverUserIds) {
console.log("IDS : " + receiverUserIds.request_ids);
$.ajax({
type: "POST",
url: "<?php echo $_SERVER['PHP_SELF']; ?>",
friends_invite: receiverUserIds.request_ids,
success: function(msg){
/* alert( "Data Saved: " + msg ); */
}
});
}
and on the same page:
if(isset($_POST['friends_invite'])){
print_r($_POST['friends_invite']);
}
but it doesn’t seem to work.
something might be wrong with either the ajax or i don’t know. maybe you guys can suggest another way of doing this..??
any ideas?
Thanks
edit: if i enable the alert lert( "Data Saved: " + msg ); i get an alert so i know that the ajax is successful, but i don’t see my $_POST being echoed out
This method should work fine. First thing that sticks out is that you should be using the
dataoption to pass the data. See the specs of the documentation for more info.