Ale*_*nco 5 iphone web-applications sencha-touch cordova
我有这段代码用于加载存储在phonegap(iPhone)项目同一目录中(通常在“www”文件夹中)的json文件,我如何访问“routes.json”?我的项目有这个树文件夹:
__万维网/
_ _ _index.html
_ _ _index.json(此代码位于何处)
_ _ _routes.json*
store: new Ext.data.Store({
model : 'routes',
proxy: {
type: 'ajax',
url : 'file://??????/www/routes.json',
reader: {
type: 'json'
}
},
autoLoad: true
})
Run Code Online (Sandbox Code Playgroud)
我认为这是 Sencha Touch Ext.data.Proxy 实现中的一个错误。我花了几个小时试图完成这项工作但没有成功。我用了不到 5 分钟就用 jQuery 实现了它。
//Initialize the Store
new Ext.data.Store(
{
model: "Routes",
storeId: "Routes",
//The Proxy isn't used but it is a required configuration option
proxy: {
type: 'ajax'
}
});
//Populate the store using jQuery.get()
$.get('routes.json',
function(data, status, jqXHR) {
if(status == "success") {
var store = Ext.StoreMgr.get('Routes');
store.loadData(data);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7466 次 |
| 最近记录: |