页面无限时间重新加载问题

时间:2019-06-09 08:44:10

标签: javascript php google-oauth

当用户成功登录页面重新加载无限时间时,我正在使用JavaScript和PHP的Google OAuth

<script>
  function onSignIn(googleUser) { 

    var profile = googleUser.getBasicProfile(); 
    var id= profile.getId(); 
    var name=profile.getName(); 
    var image=profile.getImageUrl(); 
    var email=profile.getEmail();
    var id_token = googleUser.getAuthResponse().id_token;

    $.ajax({
     url:'google-login',
     method:'post',
     data:{name,image,email,id,id_token},
     }).done(function() {
      window.location.reload();
     });

  }

<script>

我希望用户一次成功登录google OAuth API页面成功注册/登录。

1 个答案:

答案 0 :(得分:0)

    $.ajax({
    url:'google-login',
    method:'post',
    data:{name, image, email, id, id_token},
    success: function(data) {
       if (data.success == true) 
            setTimeout(function(){ 
             window.location.reload(); 
             }, 5000);
            }               
   });