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) {
      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">
  <input type="submit" Value="Login" />

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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.

    (page transition in the example is set to none) you can choose one from here --

     $( ":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.

    To Open the error dialog

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题