George_Fal 2015-08-12 19:04 采纳率: 0%
浏览 31

Phonegap多页

I'm currently working on an application in cordova. Since I have more pages I tried to add a menu. On the first page (index.html) there is some output, on the second file (settings.html) I want to make a Ajax-Request to a external server.

In the <head>-Tag all stylesheets and jQuery and Cordova is included. In the <body>-Tag some Ajax-calls are made.

<head>

<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/start/jquery-ui.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
<script type="text/javascript" src="cordova.js"></script>
</head>

<body onload="onLoad();">    
<div data-role="controlgroup" data-corners="false">
  <a href="index.html">Home</a>
  <a href="settings.html">Settings</a>
</div>
<!-- Ajax Requests -->
</body>

If I hit Settings I get to the html-page and the code will be displayed, but the code jQuery/js-code will not be executed. (I tried an alert, but it's not working)

Can you tell me what possibilities I have to include another page with working js-code?

Thanks!

  • 写回答

2条回答 默认 最新

  • weixin_33697898 2015-08-12 19:13
    关注

    You need to include a script that will fire when the page is fully loaded into the DOM.

     <script>
          $(document).ready(function(){
              -- call your$.ajax({}) here --
          });
     </script>
    

    OR

     <script>
      (function(){
         call your $.ajax({}) here --
       }();
     </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用