jQuery 中的 location.href 无法使用最新的 Safari

Latest Safari not working with location.href in jQuery

有人知道这个问题的答案吗?

基本上我已经用尽了这里其他问题的所有可能答案,我迫不及待地打开一个新的求助电话!

问题...我有一个包含登录表单的登录页面。提交按钮附有 jQuery 点击功能。点击函数有一个 ajax 调用某些 php 检查数据库。成功后,该位置将重定向到另一个页面。现在这适用于除最新版本的 safari 之外的所有浏览器!我也尝试过不同版本的jQuery。这是非常令人沮丧的。请参阅下面的代码。

任何 suggestions/solutions 将不胜感激。

提前致谢。

------------更新---------

任何遇到这个问题的人,我想出的解决方案是重写 AngularJS 中的解决方案。我建议你也这样做!

希望对您有所帮助。

------------HTML-------------

<form id="loginFRM" style="text-align: center;">
      <input style="margin:20px; padding-left:5px;" id="username" name="username" type="text" placeholder="Username...">
      <br>
      <input style="margin:20px; padding-left:5px;" id="password" name="password" type="password" placeholder="Password...">
      <br>
      <input style="margin:20px; background-color: white; border: none; padding:10px; padding-left:30px; 
             padding-right:30px;" id="loginBtn" type="submit" value="Login" onclick="return false;">
    </form>

------------jQuery------------

$(document).ready(function(){
  $('#loginBtn').click(function(){
    var username = $("#username").val(),
            password = $("#password").val();

    if(username != "" && password != ""){
      $.ajax({
        type: "GET",
        url: './server/index.php',
        data: {
          username: username,
          password: password
        },
        success: function(response)
        {
          rowCount = response.ResultSet.RowCount;
          if(rowCount > 0){
              window.setTimeout(function(){ location.href = "index.html"; },0);
              return false;
          }
          else{
            alert('Incorrect details');
          }
        }
      });
    }else{
      alert('Incorrect details');
    }

    return false;

  });
});

试一试:

------------HTML-------------

<form id="loginFRM" style="text-align: center;">
      <input style="margin:20px; padding-left:5px;" id="username" name="username" type="text" placeholder="Username...">
      <br>
      <input style="margin:20px; padding-left:5px;" id="password" name="password" type="password" placeholder="Password...">
      <br>
      <input style="margin:20px; background-color: white; border: none; padding:10px; padding-left:30px; 
             padding-right:30px;" id="loginBtn" type="submit" value="Login">
    </form>

------------jQuery------------

$(window).load(function(){
  $('#loginBtn').click(function(event){
    event.preventDefault();
    var username = $("#username").val(),
            password = $("#password").val();

    if(username != "" && password != ""){
      $.ajax({
        type: "GET",
        url: './server/index.php',
        data: {
          username: username,
          password: password
        },
        success: function(response)
        {
          rowCount = response.ResultSet.RowCount;
          if(rowCount > 0){
              window.setTimeout(function(){ location.href = "index.html"; },0);
              return false;
          }
          else{
            alert('Incorrect details');
          }
        }
      });
    }else{
      alert('Incorrect details');
    }

    return false;

  });
});

任何遇到这个问题的人,我想出的解决方案是重写 AngularJS 中的解决方案。我建议你也这样做!