【问题标题】:PhoneGAP: Ported working code from Android platform to iOSPhoneGAP:将工作代码从 Android 平台移植到 iOS
【发布时间】:2013-09-08 12:37:35
【问题描述】:

我最近完成并提交了 Android 调查应用的离线版本。

现在“代码”又名 www 目录正在移植到 iOS。

我认为 AppCode 和 Xcode 都很难使用 - 这可能是因为调试没有针对 Web 编码进行优化。 昨晚我花了 1.5 个小时查看拼写错误“serInterval”->“setInterval”。 这很容易被 IntelliJ IDEA 识别。

现在我遇到了一些 SQlite 代码,它应该将调查的答案存储在本地数据库中,并在设备上线时将其同步到我们的云系统。

我可以通过 console.log() 看到我的函数正在运行,但我的表中没有任何内容。

将调查发布到本地数据库的代码是:

$(document).ready(function() {
        $('input#submitForm').live('click', function() {
            var formData = $('#questForm').serializeArray();
            var jsonFormData = JSON.stringify($('#questForm').serializeObject());
            jQuery.ajaxSetup({
                beforeSend: function() {
                    $("body").addClass("loading");
                    dbConnect();
                    storeAnswer(uniqueID,readerID,jsonFormData);
                    console.log("Barcode: "+barcode+" VisitorID: "+visitorID+" UniqueID: "+uniqueID+" - "+readerID);
                },
                complete: function(){
                    window.location.href = 'surveyScan.html';
                },
                success: function() {}
            });
            try {
                $.post(null,function(){});
            }
            catch(e) {
                console.error("Error using mycommand: " + e.message);
            }
        });
    });

日志消息打印出我所期望的...

storeAnswer 函数:

function storeAnswer(visitor_ID, reader_ID, formData) {
    console.log('storeAnswer()');
    html5sql.process(
        ["INSERT INTO Answers (_id, visitorUID, readerID, json) VALUES (null,'"+visitor_ID+"','"+reader_ID+"','"+formData+"');"],
        function(){
            console.log('Inserted 1 row into table: Answers!');
        },
        function(error, statement){
            console.error("storeAnswer: Error: " + error.message + " when processing " + statement);
        }
    )

}

在 storeAnswer() 中,仅打印第一条日志消息 (storeAnswer())...

如果您需要其他详细信息,请告诉我。

【问题讨论】:

    标签: jquery ios sqlite jquery-mobile cordova


    【解决方案1】:

    在您的 Xcode 首选项中下载组件并安装 CLI 工具 然后打开 safari > 进入 safari >preference >Advanced >在菜单栏中显示开发菜单。

    现在在模拟器上运行你的应用 开放游猎 转到开发菜单 > iPhone 模拟器 > 你的页面 现在你可以在控制台输入 location.href="index.html" 重新加载页面并找出您想要的任何内容。 此外,所有 phonegap 对象都可以从这里访问

    用于在 sqlite db 中进行自定义添加 n 删除 /Users/username/Library/Application Support/iPhone Simulator/6.1/Applications 导航到 app 文件夹(如果正在那里创建 sqlite 数据库) 然后做 sqlite3 dbname & 然后尝试做你的 sqlite 3 操作 然后可以将相同的内容合并到您可以从浏览器控制台调用的 JS 中。

    【讨论】:

      猜你喜欢
      • 2015-07-15
      • 1970-01-01
      • 2012-03-01
      • 2011-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-07
      • 1970-01-01
      相关资源
      最近更新 更多