Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance jquery mobile中的.get()方法不';更改页面时无法加载_Performance_Jquery_Cordova_Jquery Mobile_Jquery Get - Fatal编程技术网

Performance jquery mobile中的.get()方法不';更改页面时无法加载

Performance jquery mobile中的.get()方法不';更改页面时无法加载,performance,jquery,cordova,jquery-mobile,jquery-get,Performance,Jquery,Cordova,Jquery Mobile,Jquery Get,我有一个用phonegap构建的移动应用程序,我正在使用jquery mobile。在第一页上,我有另一个链接,href=“page2.html” 加载第二个页面时,我使用.get()检索xml数据,并使用xml2json.js将其转换为json。如果我将此页面作为索引,并在应用程序打开时加载它,则该页面可以正常工作,因此我知道脚本正在工作。但是,当从另一个页面通过链接加载时,.get()方法似乎不会加载任何数据 <script type="text/javascript" src="co

我有一个用phonegap构建的移动应用程序,我正在使用jquery mobile。在第一页上,我有另一个链接,href=“page2.html”

加载第二个页面时,我使用.get()检索xml数据,并使用xml2json.js将其转换为json。如果我将此页面作为索引,并在应用程序打开时加载它,则该页面可以正常工作,因此我知道脚本正在工作。但是,当从另一个页面通过链接加载时,.get()方法似乎不会加载任何数据

<script type="text/javascript" src="cordova-2.4.0.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
        <script type="text/javascript" src="js/jquery.xml2json.js"></script>
        <script type="text/javascript">
            $.get('http://domain.com/app/getfacilities/?org=mysite', function(xml){
                  var facilities = $.xml2json(xml);
                  for (i=0; i<=facilities.facility.length; i++){
                    var locName = facilities.facility[i].name;
                    var id = facilities.facility[i].id;
                    $("#fieldList").append("<li><a href='#'>" + locName + "</a></li>").listview('refresh');
                  }
                  });
            </script>
        <script type="text/javascript">
            app.initialize();
        </script>

$.get('http://domain.com/app/getfacilities/?org=mysite,函数(xml){
var facilities=$.xml2json(xml);

对于(i=0;i您需要将
标记放在
标记内。
标记外的
标记只会在第一次/初始页面加载时加载,这似乎与您的体验一致

<div data-role="page">
    <script>
        // js script here
    </script>
</div>

//js脚本在这里

那些脚本标记(在page2.html中),它们是头部还是身体的一部分?它们在身体中,就在/BODY标签上方。糟糕,仍然不起作用。当同时使用jqmobile和phonegap时,我是否必须在我创建的每个页面上都包含所有这些脚本?我已经用Nimblekit构建了应用程序,这非常简单。我觉得我遗漏了一些东西:-(.太好了,这很有效。只需从页面中删除所有脚本,并将.get()方法包含在body.Tks、@andleer!