javascript - 谷歌+登录错误。阻止了来源为 "http://localhost"的帧

标签 javascript jquery google-plus google-signin

我正在我的网站中应用 google+ 登录。但是当我将数据发送到我的服务以将其保存在数据库中时,它会给出以下错误:

Uncaught SecurityError: Blocked a frame with origin "http://localhost" from accessing a frame with origin "https://apis.google.com". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.

我的代码是:这个函数填充文本框中的值。并且值被正确填充。

function signinCallback(authResult) {
if (authResult['status']['signed_in']) {
    gapi.client.load('plus', 'v1', function() {
        var request = gapi.client.plus.people.get({
            'userId': 'me'
        });
        request.execute(function(resp) {
            var googleId = resp.id;
            var name=resp.displayName
            isGoogleSignUp(googleId, function(res) {
                if (res) {
                    window.location = "profile.php";
                } else {

                    $("#loginPopup").css("dispaly", "none");
                    $("#signupPopup").css("display", "block");
                    $("#socialName").val(name);
                    //$("#socialMail").val();
                    $("#socialId").val(googleId);
                    $("#socialType").val("google");
                  }
               });
           console.log(resp);

           });
      });
} else {
    console.log('Sign-in state: ' + authResult['error']);
}
}

通过单击提交按钮调用此函数时会出错 -

function socialSignUp1() {
var urlString = "Service/socialSignup.php";
var form = new Object();
form.socialId = $("#socialId").val;
console.log(form.socialId);
form.type = $("#type").val();
form.name = $("#socialName").val();
form.mail = $("#socialMail").val();
form.phone = $("#socialPhone").val();
form.address = $("#socialAddress").val();
$.ajax({
    type: 'POST',
    data: form,
    url: urlString,
    success: function(resultData) {
        if (resultData == 1) {
            window.location("profile.php");

        }
    },
    error: function(resultData) {
        alert(resultData);
    },
    failed: function() {
        alert("hello");
    }
  });
 }

最佳答案

正如您的错误消息所示:

The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.

因此,请更改您正在使用的协议(protocol)。

关于javascript - 谷歌+登录错误。阻止了来源为 "http://localhost"的帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27170021/

相关文章:

javascript - 像 G+ 这样的电子邮件中的 javascript 下拉列表可以由任何人实现,还是只能由 Google 实现?

javascript - 如何将 Facebook/Google+/Twitter 共享按钮添加到移动应用程序 (PhoneGap)

javascript - 粘性页脚,以及没有特定高度的滚动 div

javascript - 我如何访问 SOAP 响应属性?

javascript - iOS 8 Beta 5 Safari 多张照片上传

javascript - 提交表单之前使用确认对话框的正确方法

javascript - 使用 jQuery .each 迭代关联数组

ios - 尝试不使用 Google+ 按钮的 SilentAuthentication

javascript - 删除并清除选定的属性过滤器

jquery - 在datalist中找到div并提交按钮