doulan4939 2015-01-27 17:31
浏览 66
已采纳

在IE中使用锚点的Jquery Mobile重定向

My code is running on jquery mobile 1.4.5. When i submit the form. The website will make a call to login.php and if it succeeds it will redirect to the #customer anchor. If not it will redirect to the #error popout. The problem is that this works as expected on chrome and firefox however it does not work on desktop IE11.

$(document).ready(function() {
  $('#loginform').submit(function(e) {
    e.preventDefault();
    $.ajax({
      type: "POST",
      url: 'login.php',
      data: $(this).serialize(),
      success: function(data) {
        if (data === 'login') {
          window.location = '#customer';
        } else {
          window.location = '#error';
        }
      }
    });
  });
});
<form id="loginform" method="post">
  <div class="ui-field-contain">
    <label for="storeID">Store ID:</label>
    <input type="text" name="usn" id="usn">
    <label for="password">Password:</label>
    <input type="password" name="upw" id="upw">
  </div>
  <input type="submit" Value="Login" />
</form>

</div>
  • 写回答

1条回答 默认 最新

  • dsiv4041 2015-01-27 19:18
    关注

    JQM has its own widget for navigating to Pages. It loads pages using Ajax into the Dom or once loaded into the Dom it directs to that Page. The Widget used is called Pagecontainer using Change Method.

    Now i dont know about IE11, never used it, but per JQM user guide the following way is the one you need to use.

    http://api.jquerymobile.com/pagecontainer/

    (page transition in the example is set to none) you can choose one from here --http://demos.jquerymobile.com/1.4.5/transitions/

     $( ":mobile-pagecontainer" ).pagecontainer( "change", "#customer", { transition: "none" })
    

    if you want a reverse transition, ie going the other way round use reverse true

     $( ":mobile-pagecontainer" ).pagecontainer( "change", "#customer", { transition: "none", reverse: true })
    

    For the error dialog JQM has a widget for that too.

    http://api.jquerymobile.com/dialog/

    To Open the error dialog

    $.mobile.changePage( "#error", { role: "dialog" } );

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么