我正在我的网站上使用google +登录名。但是,当我将数据发送到我的服务以将其保存到数据库时,出现以下错误:
未捕获到的SecurityError:阻止了源为"http://localhost"
的帧访问源为“ https://apis.google.com”的帧。请求访问的帧的协议为“ http”,正在访问的帧的协议为“ https”。协议必须匹配。
我的代码是:此函数填充文本框中的值。并且值被正确填充。
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");
}
});
}
最佳答案
如您的错误消息所述:
请求访问的帧的协议为“ http”,正在访问的帧的协议为“ https”。协议必须匹配。
因此,更改您正在使用的协议。
关于javascript - google +登录错误。阻止了源为“http://localhost”的帧,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27170021/