Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.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
Jquery 另一页上的json查询_Jquery_Json - Fatal编程技术网

Jquery 另一页上的json查询

Jquery 另一页上的json查询,jquery,json,Jquery,Json,我正在编写一个简单的JSON/HTML/JQuery移动应用程序 我的主页(index.html)包含以下代码: <script type="text/javascript"> $(document).on('pageinit', '#index', function(){ var url="http://localhost/json/jsondata.aspx?Option=GetTodaysEvents"; $.g

我正在编写一个简单的JSON/HTML/JQuery移动应用程序

我的主页(index.html)包含以下代码:

<script type="text/javascript">
        $(document).on('pageinit', '#index', function(){ 
            var url="http://localhost/json/jsondata.aspx?Option=GetTodaysEvents";
            $.getJSON(url,function(json){
                //loop through events
                $.each(json.Events,function(i,dat){
                    $("#todaycal").append("<li>"+dat.Date+"  "+dat.Title+"</li>");
                 });
                 $("#todaycal").listview('refresh');
            });
         });
    </script>

$(document).on('pageinit','#index',function(){
变量url=”http://localhost/json/jsondata.aspx?Option=GetTodaysEvents";
$.getJSON(url,函数(json){
//循环浏览事件
$.each(json.Events,function(i,dat){
$(“#今天”)。追加(“
  • ”+dat.Date+“+dat.Title+”
  • ”); }); $(“#todaycal”).listview('refresh'); }); });
    它在以下区域中大量存在:

    <ul id="todaycal" data-role="listview" data-inset="true"><li data-role="list-divider">Today's Events</li></ul>
    
    • 今天的事件
    这是正确的

    但是如果我导航到calendar.html

    并且运行相同的代码,listview不会填充。我试着把pageinit改为pagebefore show。我已将#索引更改为#日历,我已更改listview id,等等

    我这样做是正确的还是应该在后续页面上使用不同的代码?DW中的“实时”页面视图显示查询。但当我在phonegap中打包时,我得到的是UL头,而不是数据元素


    有什么想法吗?

    这两个页面上都有JS代码吗?如果你自己打开calendar.html,它在那里工作吗?是的,但只在电脑上工作。如果我在手机上打包、安装并加载应用程序,第一页工作,而不是第二页。当你在手机间隙中打包时,你的url是否仍指向本地主机?当我说json是由本地机器上的服务生成时,为了保密起见,我刚刚在帖子中更改了URL。它指向一个可访问的服务器。