【问题标题】:ajax doesn't work on galaxy s4 with cordova 3.0ajax 不适用于带有 cordova 3.0 的 Galaxy s4
【发布时间】:2013-07-24 10:36:54
【问题描述】:

我开始使用 cordova 和 jqmobile。

我在这里遵循了一些指南和一些帖子,但没有一个对我有帮助。 我创建了一个简单的测试应用程序,它带有一个返回一些值的 ajax 调用。它适用于某些 android 的手机(即 Google nexus 与 android 4.2 ,galaxy ace 与 android 2.3 )但它不适用于我的galaxy s4。

我错过了什么?

这是我的 index.js

var deviceReadyDeferred = $.Deferred();
var jqmReadyDeferred = $.Deferred();
document.addEventListener('mainpage',deviceReady(),false);
function deviceReady(){
    deviceReadyDeferred.resolve();
}
$(document).on('mobileinit',function(){
    jqmReadyDeferred.resolve();
});
$.when(deviceReadyDeferred,jqmReadyDeferred).then(doWhenBothFrameworksLoaded());
function doWhenBothFrameworksLoaded (){
    $.mobile.allowCrossDomainPages = true;
    $.support.cors = true;
    loadRepos();
}

loadRepos() 函数包含 ajax。

 <html>
    <head>
    <meta charset="utf-8" />
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, height=device-height initial-scale=1">
    <link rel="stylesheet" href="assets/jquery.mobile/jquery.mobile-1.3.1.min.css" />
    <script src="assets/jquery/jquery-1.10.2.min.js"></script>
    <script src="assets/jquery.mobile/jquery.mobile-1.3.1.min.js"></script>
    </head>
    <body>

  <div data-role="page" id="mainpage">

    <div data-role="header" data-position="fixed" id="deviceready">
      <h1>Ticket Test</h1>
      <div data-role='navbar'>
        <ul>
          <li><a href="#mymenu" data-inline='true' data-icon="grid">Menu</a></li>
          <li><a href="#popupMenu" data-rel="popup"
              data-role="button" data-inline="true"
              data-transition="slideup" data-icon="gear" data-theme="e">Options</a></li>
          <li><a href="#mycerca" data-icon="search"
              data-inline='true'>Cerca</a></li>
        </ul>
      </div>
    </div>

    <div data-role="content">
      <h2>Dashboard</h2>
      <table id="dashboard" data-role="table" data-mode="columntoggle"
        class="ui-responsive table-stroke" data-filter="true">
        <thead>
          <tr>
            <th>Number</th>
            <th data-priority="2">Company</th>
            <th data-priority="3">Queue</th>
            <th data-priority="4">Receiver</th>
          </tr>
        </thead>
        <tbody>
        </tbody>
      </table>
    </div>
  </div>
  <script type="text/javascript" src="cordova.js"></script>
  <script type="text/javascript" src="js/index.js"></script>
</body>
</html>

【问题讨论】:

    标签: android ajax cordova galaxy


    【解决方案1】:

    您在以下行中有错误: document.addEventListener('mainpage',deviceReady(),false);

    应该是:
    document.addEventListener('mainpage',deviceReady,false);

    即函数名,而不是函数调用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多