Мой код берет информацию об учетной записи Google и печатает ее на консоли Google, но функция javascript не срабатывает.Даже alert("hello")
не работает.Может ли кто-нибудь, пожалуйста, скажите мне, почему.
<head>
<meta name="google-signin-client_id" content="client id">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn();"></div>
<a href="#" onclick="signOut();">Sign out</a> </body>
function onSignIn(googleUser) {
alert("hello");
var profile = googleUser.getBasicProfile();
var id = profile.getId(); // Do not send to your backend! Use an ID token instead.
var name = profile.getName();
var email = profile.getEmail(); // This is null if the 'email' scope is not present.
console.log("name is" + name);
$.ajax({ // defining the below function as ajax responsive//
url: 'googlesignin', // the function that process the mapped url name and matching type is going to receive the data//
type: 'POST',
data: {
id: id,
name: name,
email: email
}, // function to get the value from jsp page and send it to mapped class function//
success: function(response) { // if the backend process is success then the function will run by getting the response as its parameter//
alert(response.message);
},
error: function(response) {
alert("unable to sign in");
}
});
}