Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
60
rated 0 times [  61] [ 1]  / answers: 1 / hits: 22157  / 12 Years ago, mon, may 14, 2012, 12:00:00

Hey friends i am using javascript sdk to post on users friends wall with jQuery facebook multi friend selector however i am getting this error friendId.split is not a function. Here is my code



function recommendToFriend(pic, url, friendId, fromName)
{
alert(friendId);
var friendList ;
pFriend = new Array();
pFriend = friendId.split(',');
for( x in pFriend )
{
alert(pFriend[x]);
var publish = {
method:'feed',
picture:pic,
link:url,
name:'SHARP Product Recommend',
caption: fromName + 'has recommend a product to you via Sharp Expert lounge',
};

FB.api('/'+pFriend[x]+'/feed', 'post', publish, function(resp) {
if( !response || response.error )
alert('Unable to share');
else
alert('Successfully posted to firends wall');
});
}
}


In alert box i got comma seperated friend ids so i use split function post on each users wall seperately i dont know whats wrong here please help me


More From » jquery

 Answers
77

You can traverse JS Objects like this



for (var key in friendid) {
var obj = friendid[key];
for (var prop in obj) {
alert(prop + = + obj[prop]);
}
}


Hope this helps



alternate



for( var x in friendId )
{
alert(friendId[x]); // this would be your desired value
}

[#85598] Saturday, May 12, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dajah

Total Points: 208
Total Questions: 97
Total Answers: 87

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;