Jquery Mobile正在向页面传递未知参数


Jquery Mobile passing unknown parameter to page

我发现我的网站有问题,我已将其隔离到Jquery Mobile组件。我只是点击一个href链接,该链接调用另一个PHP页面。在第二个页面上,我设置了一个表单和一个Jquery表单验证,检查是否选择了SKU按钮,如果选择了,它应该返回警报并取消表单提交。问题是,当我从第一页链接到第二页时,表单验证代码不起作用。

如果我刷新页面,它会正常工作。我隔离了Jquery Mobile的链接,页面运行得很好。Jquery Mobile正在传递一些东西,阻止页面整体加载。或者,更有可能的是,第一页有一些结转,禁用了第二页上的验证代码。

我可以补充一点,如果我在第二页上完全删除了Jquery Mobile的链接(根本没有样式),并从第一页链接到第二页,Jquery Mobile格式仍然会转到第二页。我已经对此进行了广泛的调查,我找不到以前提到过这个问题。我已经设置了测试页面来解决这个问题。

第1页:

<html lang="en">
<head>
  <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1" >
  <title>Customer Maintenance</title>
  <link rel="stylesheet" type="text/css" href="styles.css" />
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js">     </script>
 </head>
 <body> 
Test 1 page
<p><a href="test1.html">Home Page</a></p><hr>
  <footer>Created by: attentionjay</footer>
 </body>
 </html>
<a href="test2.php" >Test Inventory</a>

第2页:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1" >
  <title>Customer Maintenance</title>
  <link rel="stylesheet" type="text/css" href="styles.css" />
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
  <script>
  $(function () {
          $('#custalert').bind('submit', function (e) {
              if($("input:first").val() == "") {
              alert("You must enter a Customer Alert");
              return false;
             }
        });
    });
  $(function () {
          $('#queryinv').bind('submit', function (e) {
              if($('#sku_checkbox').is(':checked') == true) {
             alert("You must enter a SKU");
             return false;
            }
        });
    });    
</script>
 </head>
 <body> 
 <div data-theme='a' > 
    <div style="padding:10px 20px;">
        <form action="inventory_inquiry.php" method="get" id="queryinv" >           
         <h3>Enter SKU</h3>
         <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
          <legend>Choose Input Type:</legend>
          <input type="radio" data-theme="a" name="input" id="sku_checkbox" />
          <label for="sku_checkbox">SKU</label>
          <input type="radio" data-theme="a" name="input" id="entire_checkbox" />
          <label for="entire_checkbox">Entire Inventory</label>
         </fieldset>
            <label for="sku" class="ui-hidden-accessible">SKU:</label>
            <input type="text" name="sku" id="sku" value="" placeholder="Item SKU" data-theme="a">
            <input name="customer_id" type="hidden" value='<?php echo $customer_id; ?>'/>
            <button type="submit" data-theme="b">Submit</button>
        </form>    
    </div>
</div> 
  <br>
 <p><a href="test1.html">Home Page</a></p><hr>
  <footer>Created by: attentionjay</footer>
 </body>
 </html>

我能得到的任何帮助都会很棒。这对我来说是个谜。

编辑:2013年7月7日我认为在解决这个问题的同时,更新我的发现是值得的。禁用AJAX数据有效,但仅适用于链接。我很难让它在提交表格时发挥作用。我最终使用以下脚本全局禁用AJAX:

<script>$(document).bind("mobileinit", function(){
  $.mobile.ajaxEnabled = false;
 });</script>

此脚本必须放置在页面上Jquery Mobile脚本之前。这将禁用整个页面的AJAX功能。AJAX非常棒,应该尽可能使用它。在我发现自己的问题之前,我已经设置好了网站的布局。可以更容易地对网站进行改造,以利用Jquery Mobile功能。

无论何时链接到单独的php或html页面,都可以尝试将data-ajax="false"添加到<a>标记中。

jQuerymobile是为开发人员设计的,可以将多个页面放在同一个html或php文件中。因此,它使用ajax在那些实际上只是div的"页面"之间进行链接。这样做的问题是,默认情况下,jQuerymobile对每个链接都使用ajax,除非您另有说明。这可能会产生一些棘手的问题,我花了一段时间才明白我刚开始使用jQuery mobile的时候。我认为JQM文档中有一个关于这个主题的非常好的文档。

添加rel="外部"适用于我