我最近完成并提交了我们的Android调查应用程序的离线版本。
现在,“代码”,也就是www-directory正在被移植到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())...
如果您需要其他详细信息,请让我知道。
发布于 2013-09-27 02:19:39
在您的Xcode首选项中,下载组件并安装CLI工具,然后打开safari >转到safari >首选项>高级>在菜单栏中显示开发菜单。
现在在模拟器上运行你的应用程序打开safari转到开发菜单> IPhone模拟器>你的页面现在你可以在控制台中输入location.href="index.html“来重新加载页面并找出你想要的任何东西。另外,所有的phonegap对象都可以从这里访问
要在sqlite db /Users/username/Library/Application Support/iPhone Simulator/6.1/Applications中执行自定义的添加n删除操作,请导航到应用程序文件夹(如果在那里创建了sqlite数据库),然后执行sqlite3 dbname &然后尝试执行SQLite3操作,然后可以将相同的操作合并到JS中,您可以从浏览器的控制台调用该JS。
https://stackoverflow.com/questions/18623421
复制相似问题