javascript - Uncaught TypeError: Cannot read property 'friends' of null -
i have facebook multifriends selector script shows error.
script:
window.fbasyncinit = function () { //sdk loaded, initialize var curloc = window.location; fb.init({ appid: 'xxxxxxxxxxxxx', xfbml: true, version: 'v2.0' }); (function (d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) { return; } js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/sdk.js"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); fb.canvas.setautogrow(); }; function rendermfs() { // first list of friends user graph api fb.api('/me/friends', function (response) { var container = document.getelementbyid('mfs'); var mfsform = document.createelement('form'); mfsform.id = 'mfsform'; // iterate through array of friends object , create checkbox each one. (var = 0; < math.min(response.data.length, 10); i++) { var frienditem = document.createelement('div'); frienditem.id = 'friend_' + response.data[i].id; frienditem.innerhtml = '<input type="checkbox" name="friends" value="' + response.data[i].id + '" />' + response.data[i].name; mfsform.appendchild(frienditem); } container.appendchild(mfsform); // create button send request(s) var sendbutton = document.createelement('input'); sendbutton.type = 'button'; sendbutton.value = 'send request'; sendbutton.onclick = sendrequest; mfsform.appendchild(sendbutton); }); } function sendrequest() { // list of selected friends var senduids = ''; var mfsform = document.getelementbyid('mfsform'); (var = 0; < mfsform.friends.length; i++) { if (mfsform.friends[i].checked) { senduids += mfsform.friends[i].value + ','; } } // use fb.ui send request(s) fb.ui({ method: 'apprequests', to: senduids, title: 'my great invite', message: 'check out awesome app!', }, callback); } function callback(response) { console.log(response); }
Comments
Post a Comment