I found some sample code that does fb requests:
But my goal is to redirect after this jquery post? Im not familiar with jquery post….
This code just brings the dialogue box then closes. I want to refresh the page or redirect to another. I am sending the requests to fbrequests which executes some php code that stores request info to my db on my server. I tried putting the redirect there but it doesnt work.
Its
function sendRequest(to) {
FB.ui({method: 'apprequests',
message: 'data',
data: to,
title: 'Invite your Facebook friends.'},
function (response) {
if (response && response.request_ids) {
//since csv, we convert to string
var requestIds = "";
for(var i = 0; i < response.request_ids.length; i++){
requestIds = requestIds + response.request_ids[i] +",";
}
//modifications
//now requestIds is 123,124,125, so we need to remove the last comma after the last id
requestIds = requestIds.substring(0,requestIds.length-1);
jQuery(function(){
jQuery.post("fbrequests", { request_ids: requestIds } ); //jquery post to send csv list of ids to php processing file
// window.location.href='http://mysite.com/my-friends';
});
} else {
//Do something if they don't send it.
//alert("Didnt send it");
}
});
}
Remove the wrapping
jQuery(function(){});and just use:Also use the below to join the
request_idsinstead of your code:Taken from my tutorial: How To: Handle Application Requests Using The Facebook Graph API