Facebook JS SDK无法使用ajax [英] Facebook JS SDK wont work with ajax

查看:56
本文介绍了Facebook JS SDK无法使用ajax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想要完成的是从Facebook获取朋友,然后将所有朋友发送到我的服务器以便按照处理方式进行处理。如果我不插入ajax语句,那么eveyrhtign可以工作,但是一旦我插入ajax语句,我就再也看不到连接到facebook了。我也愿意采取其他任何方式。



<前lang =Javascript>得到朋友
FB.api(' / me / friends' function (响应) {
var result_holder = document .getElementById( ' result_friends');
var friend_data = response.data.sort( sortMethod);



$ .ajax({
url:' test.php'
data:friend_data,
type:' POST'
dataType:' json',
缓存: false
成功: function (responseJSON){
alert( HELLO);
});




。更多东西

解决方案

.ajax({
url:' test.php'
data:friend_data,
type:' < span class =code-string> POST',
dataType:' json'
cache: false
成功: function (responseJSON) {
alert( HELLO);
});




。更多东西


您好,



请点击以下链接:



让Facebook的JavaScript SDK与您的AJAX页面配合使用


感谢您的回复。但我不明白这是如何工作的。我复制了代码,更改了我的应用程序ID,没有任何反应,它只是一个简单的div出现。请帮忙。


Hello, what I a trying to accomplish is to get friends from facebook and then send all the friends to my server to process them accoridngly. SO eveyrhtign works if I dont insert the ajax statement, but as soon as I insert the ajax statement I do not see connect to facebook anymore. I am open to any other ways of doing this as well.

get friends
                FB.api('/me/friends', function(response) {
                    var result_holder = document.getElementById('result_friends');
                    var friend_data = response.data.sort(sortMethod);



                $.ajax({
                url: 'test.php',
                data: friend_data,
                type: 'POST',
                dataType: 'json',
                cache: false,
                success: function(responseJSON) {
                alert("HELLO");
                });

                                    .
                                    .
                                    .
                                    . more stuff

解决方案

.ajax({ url: 'test.php', data: friend_data, type: 'POST', dataType: 'json', cache: false, success: function(responseJSON) { alert("HELLO"); }); . . . . more stuff


Hi,

Please follow the below link:

Making Facebook’s JavaScript SDK work with your AJAX pages


Thanks for the reply. But I do not understand how this works. I copied the code, changed my app id, and nothing happens, it just a plain div that show up. Please help.


这篇关于Facebook JS SDK无法使用ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆