Javascript 在jquery mobile中,pagebeforeshow返回并转到下一页时出现问题

Javascript 在jquery mobile中,pagebeforeshow返回并转到下一页时出现问题,javascript,jquery,html,jquery-mobile,Javascript,Jquery,Html,Jquery Mobile,我使用pagebeforeshow到一个页面来获取JSON数据,并从该页面返回,一遍又一遍地显示同一页面,然后再次单击返回到前一页面,与从该特定页面返回下一页面相同。任何建议,请谢谢 代码如下: $(document).on('pagebeforeshow', '#pagethree', function(e) { //alert("inpGrid"); var i = 0; var url = "http://192.168.0.101:8080

我使用pagebeforeshow到一个页面来获取JSON数据,并从该页面返回,一遍又一遍地显示同一页面,然后再次单击返回到前一页面,与从该特定页面返回下一页面相同。任何建议,请谢谢

代码如下:

$(document).on('pagebeforeshow', '#pagethree', function(e) {
        //alert("inpGrid");
        var i = 0;
        var url = "http://192.168.0.101:8080/iConfig/html5_XV/slideDemo/json/listinp.json";
             // var url = "http://api.openweathermap.org/data/2.5/forecast?lat=35&lon=139&callback=?" ;
              $.getJSON(url, function(res) {
                  console.log(res)
                  var attr = "";
                   $.each(res.response.output.records, function(i, v) {
                                  $.each(res.response.output.fieldInfo, function(index, value) {

                                        if (index == 0 && offset==v[value["label"]]) {
                                            attr =1;
                                        }
                                        if(attr == 1){
                                            if(index == 0){
                                                document.getElementById('inpName').value = v[value["label"]];
                                                inpName = v[value["label"]];
                                            }
                                            if(index == 1){
                                                document.getElementById('inpAlias').value = v[value["label"]];
                                                inpAlias = v[value["label"]];
                                            }
                                            if(index == 2){
                                                document.getElementById('inpDataType').value = v[value["label"]];
                                                inpDataType = v[value["label"]];
                                            }
                                            if(index == 3){
                                                document.getElementById('inpDefault').value = v[value["label"]];
                                                inpDefault = v[value["label"]];
                                            }
                                            if(index == 4){
                                                document.getElementById('inpVisible').value = v[value["label"]];
                                                inpVisible = v[value["label"]];
                                                attr = "";
                                            }
                                        }
                                  });
                 });

            });
});
而pagethree.html看起来像

<html>
<body>

<div data-role="page" data-dialog="true" id="pagethree" data-close-btn="none">
  <div data-role="header">
    <h1>Selected Input</h1>
  </div>


  <div data-role="main" class="ui-content" style="height:300px;" >
  <div class="ui-field-contain">
         <fieldset data-role="controlgroup">
            <div data-role="fieldcontain">
                         <label for="name">Name:</label>
                         <input type="text" name="inpName" id="inpName"   disabled="disabled"/>
            </div>
            <div data-role="fieldcontain">
                                     <label for="name">Alias:</label>
                                     <input type="text" name="inpAlias" id="inpAlias"/>
            </div>
            <div data-role="fieldcontain">
                                                 <label for="name">Data Type:</label>
                                                 <input type="text" name="inpDataType" id="inpDataType"   disabled="disabled"/>
            </div>
            <div data-role="fieldcontain">
                                                 <label for="name">Default Value:</label>
                                                 <a href="listDefault.html"  data-transition="slide"><input type="text" name="inpDefault" id="inpDefault"  /></a>
            </div>
            <div data-role="fieldcontain">
            <label for="name">Visibility:</label>
                                <select name="inpVisible" id="inpVisible">
                                    <option value="0">0</option>
                                    <option value="1">1</option>
                                </select>
            </div>
         </fieldset>
         </div>
         <a href="" data-role="button" data-theme="b" id="save1" data-inline="true" data-rel="back">back</a>

    <a href="slidingdialogs.html">Go to Page One</a>

  </div>

  <div data-role="footer">
    <h1>Footer Text in Dialog</h1>
  </div>
</div>

</body>
</html>

首先尝试使用“off”$文档。关闭“pagebeforeshow”。在“pagebeforeshow”,“pagethree”上,函数{不工作,只和以前一样。我使用了绑定而不是打开,但仍然是一样的。有人能回答这个问题吗。