使用$ .get + jquery mobile读取数据库文件:在iOS上不起作用 [英] read a database file with $.get + jquery mobile : not working on iOS
问题描述
在一个jquery移动网络应用程序中,我使用$ .get将txt文件读入数组:
In a jquery-mobile web app, I read a txt file into an array using $.get :
$(document).on('pageinit','#welcome-page', function(){
var request = $.get("proDB.txt", function(data) {
var lines=data.split(/\n/);
var i;
prodata.push(0);
var fieldnames=lines[0].split(/\t/);
for (i = 1; i < lines.length-1; ++i) {
var fields=lines[i].split(/\t/);
prodata.push(i);
var j;
prodata[i]={};
prodata[i]['id']=i; //auto id, there is no more 'id' column in the DB file.
for (j = 0; j < fields.length; ++j) {
var str=fieldnames[j];
prodata[i][str]=fields[j];
}
}
//SORT BY NAME
prodata.sort(SortByName);
alert("request"+request);
}, "text");
然后在代码后面,确保$ .get完成,并使用数组:
then later in the code, I make sure the $.get is done and I use the array :
request.done(function(){...
但是alert
不会在safari的iO中弹出,而会在android浏览器和桌面firefox中弹出.
But the alert
doesn't pop in safari's iOs, whereas it pops with the android browser and with desktop firefox.
此外,我对此实在不满意,因为我想在一个单独的函数中一劳永逸地读取文件,然后能够根据需要在数组上进行尽可能多的工作.
Moreover, I am really unhappy with this as I would like to read the file once and for all in a separate function, and then be able to work on the array as much as I want.
有没有一种更干净的方式来随我的应用一起提供并将此文本文件读入数组,而不必担心它是否为".done"?像是pagebeforecreate
之类的东西?
我不得不提到,我正在从中读取数据的文件有时必须更新,因为他的服务器端克隆将不断发展.
Is there a cleaner way to ship with my app and read this text file into an array without having to worry if it's ".done" ? like with pagebeforecreate
or something like that?
I have to mention that the file I am reading the data from, will have to be updated sometimes because his server-side clone will evolve.
谢谢
推荐答案
我发现了适用于Chrome的Ripple,并且可以对此进行调试.
I discovered Ripple for Chrome, and I was able to debug with this.
这篇关于使用$ .get + jquery mobile读取数据库文件:在iOS上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!