title: Login popup not redirected after successful login in ajax
body: <p>I trying a popup on clicking login window a pop up open with URL  it asking for  username and password as well as google signin
  When the user tries to login using google sign in using pop up. After login the popup never redirects to the main page. But alert box with posting failed keeps on appearing</p>
  <pre><code> &lt;button class=&quot;btn btn-primary btn-lg&quot; href=&quot;#signup&quot; data-toggle=&quot;modal&quot; data-target=&quot;.log-sign&quot;&gt;Sign In/Register&lt;/button&gt;
  
   &lt;div class=&quot;modal-body&quot;&gt;
          &lt;div id=&quot;myTabContent&quot; class=&quot;tab-content&quot;&gt;
         
          &lt;div class=&quot;tab-pane fade active in&quot; id=&quot;signin&quot;&gt;
              &lt;form class=&quot;form-horizontal&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
              &lt;fieldset&gt;
              &lt;!-- Sign In Form --&gt;
              &lt;!-- Text input--&gt;
                
                 &lt;div class=&quot;group&quot;&gt;
  &lt;input required=&quot;&quot; class=&quot;input&quot; type=&quot;text&quot;&gt;&lt;span class=&quot;highlight&quot;&gt;&lt;/span&gt;&lt;span class=&quot;bar&quot;&gt;&lt;/span&gt;
      &lt;label class=&quot;label&quot; for=&quot;date&quot;&gt;Email address&lt;/label&gt;&lt;/div&gt;
                
                
            
              &lt;div class=&quot;group&quot;&gt;
  &lt;input required=&quot;&quot; class=&quot;input&quot; type=&quot;password&quot;&gt;&lt;span class=&quot;highlight&quot;&gt;&lt;/span&gt;&lt;span class=&quot;bar&quot;&gt;&lt;/span&gt;
      &lt;label class=&quot;label&quot; for=&quot;date&quot;&gt;Password&lt;/label&gt;
      &lt;/div&gt;
  
  
     
                 &lt;div class=&quot;or-box&quot;&gt;
                      &lt;span class=&quot;or&quot;&gt;OR&lt;/span&gt;
                      &lt;div class=&quot;row&quot;&gt;
                          &lt;div class=&quot;col-md-12&quot;&gt;
                              &lt;center&gt;&lt;div class=&quot;g-signin2&quot; data-onsuccess=&quot;onSignIn&quot;&gt;&lt;/div&gt;&lt;/center&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
              &lt;!-- Button --&gt;
              &lt;div class=&quot;control-group&quot;&gt;
                &lt;label class=&quot;control-label&quot; for=&quot;signin&quot;&gt;&lt;/label&gt;
                &lt;div class=&quot;controls&quot;&gt;
                  &lt;button id=&quot;signin&quot; name=&quot;signin&quot; class=&quot;btn btn-primary btn-block&quot;&gt;Log In&lt;/button&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;/fieldset&gt;
              &lt;/form&gt;
          &lt;/div&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
      function onSignIn(googleUser) {
        var profile = googleUser.getBasicProfile();
  
  
        if(profile){
            $.ajax({
                  type: 'POST',
                  url: 'login_pro.php',
                  data: {id:profile.getId(), name:profile.getName(), email:profile.getEmail()}
              }).done(function(data){
                  console.log(data);
                  window.location.href = 'index.php';
              }).fail(function() { 
                  alert( &quot;Posting failed.&quot; );
              });
        }
  
  
      }
  &lt;/script&gt;
  </code></pre>