PDA

View Full Version : json not loading in iphone device



susan.sarabia007
18 Aug 2011, 7:04 AM
Hello,

I'm trying to load a json into my view. Im using phonegap with sencha touch and when I load the app to my phone the json does not load at all.. It works fine in the browser and in the simulator.
I would really appreciate some help from the experts

Here is the main code that im trying:

the store:

App.stores.freebees = new Ext.data.Store({
model: 'Freebee',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'fixtures/freebees',
reader: {
type: 'json'
}
}
});

the list view:
App.views.FreebeesList = Ext.extend(Ext.List, {
id: 'indexlist',
layout: 'fit',
store: App.stores.freebees,
itemTpl: '{companyName}, {title}, {address}',


listeners: {
'itemtap': function(list, index, item, obj) {
Ext.dispatch({
controller: 'Freebee',
action: 'showDetails',
id: list.getRecord(item).data.id,
lat: list.getRecord(item).data.lat,
longitude: list.getRecord(item).data.longitude,
companyName: list.getRecord(item).data.companyName,
address: list.getRecord(item).data.address,

});
}
},
initComponent: function() {
App.views.FreebeesList.superclass.initComponent.apply(this, arguments);
}
});
console.log('dfgdfg');
Ext.reg('App.views.FreebeesList', App.views.FreebeesList);

the json:
[
{
"id": 1,
"title": "Freebee 1",
"companyName": "Företaget AB 1",
"address": "Ekuddsvägen 1 Nacka 131 38 Sweden",
"lat": 59.3058,
"longitude": 18.1463
},
{
"id": 2,
"title": "Freebee 2",
"companyName": "Företaget AB 2",
"address": "Ekuddsvägen 2 Nacka 131 38 Sweden",
"lat": 59.305,
"longitude": 18.1478
},
{
"id": 3,
"title": "Freebee 3",
"companyName": "Företaget AB 3",
"address": "Ekuddsvägen 3 Nacka 131 38 Sweden",
"lat": 59.3563,
"longitude": 18.1445
},
{
"id": 4,
"title": "Freebee 4",
"companyName": "Företaget AB 4",
"address": "Ekuddsvägen 4 Nacka 131 38 Sweden",
"lat": 59.3051,
"longitude": 18.140
},
{
"id": 5,
"title": "something freebee",
"companyName": "Appsorbance AB",
"address": "saltmätargatan 19 11359 Sweden",
"lat": 59.3408,
"longitude": 18.0570
}
]

accubook
11 Oct 2011, 4:29 AM
Hi,

Just a guess but perhaps your issue is related to this thread: http://www.sencha.com/forum/showthread.php?145073-JSON-Store-not-loading-when-added-to-Home-Screen

t (http://www.sencha.com/forum/showthread.php?145073-JSON-Store-not-loading-when-added-to-Home-Screen&highlight=ajax+iphone)he autoload:true was causing the problem

steve1964
11 Oct 2011, 7:20 AM
Hi, in a app you have to use absolute url not relative url:
replace url: 'fixtures/freebees', with url: 'http://yourdomain.com/fixtures/freebees'