Uncaught SecurityError:使用origin" http:// localhost"阻止了一个帧。从访问带有起源的框架" http://static.ak.facebook.com"

时间:2014-11-16 17:36:11

标签: php jquery facebook facebook-graph-api

我正在我的php网站上实现fb登录。当我尝试使用他的fb帐户注册用户时,它会出现以下错误 -

  

Uncaught SecurityError:阻止原始"http://localhost"的框架访问原始“http://static.ak.facebook.com”的框架。被访问的帧将“document.domain”设置为“facebook.com”,但请求访问的帧没有。两者都必须将“document.domain”设置为相同的值才能允许访问。

在我使用的php页面中 -

<script>
        window.fbAsyncInit = function() {
            FB.init({
                appId: 'myappId',
                xfbml: true,
                version: 'v2.1',
                 cookie     : true
            });
        };

        (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'));
    </script>

我的登录代码是 -

function statusChangeCallback(response) {

if (response.status === 'connected') {
    // Logged into your app and Facebook.
    isFbSignUp(response, function(res) {
        if (res) {
            window.location = "profile.php";
        } else {

            $("#loginPopup").css("dispaly", "none");
            $("#signupPopup").css("display", "block");
            FB.api('/me', function(response) {
                console.log(response);
                $("#fbName").val(response.name);
                $("#fbMail").val(response.email);
                $("#socialId").val(response.id);
                $("#socialType").val("fb");
            });
        }
    });

} else if (response.status === 'not_authorized') {
    // The person is logged into Facebook, but not your app.
    document.getElementById('status').innerHTML = 'Please log ' +
            'into this app.';
} else {
    // The person is not logged into Facebook, so we're not sure if
    // they are logged into this app or not.
    document.getElementById('status').innerHTML = 'Please log ' +
            'into Facebook.';
}

}

//此代码导致错误 -

function socialSignUp() {
var urlString = "Service/socialSignup.php";
var form = new Object();
form.socialId = $("#socialId").val;
form.type = $("#type").val();
form.name = $("#fbName").val();
form.mail = $("#fbMail").val();
form.phone = $("#fbPhone").val();
form.address = $("#fbAddress").val();
$.ajax({
    type: 'POST',
    data: form,
    url: urlString,
    success: function(resultData) {
        if (resultData == 1) {
            window.location("profile.php");

        }
    },
    error: function(resultData) {
        alert(resultData);
    }
});

}

请帮忙。

0 个答案:

没有答案