PDA

View Full Version : add json to store



borden0108
9 Nov 2011, 3:30 AM
hi all,

i have a json file on another server and do the call in json p but then it does not load into the store and then into my list





var store;
Ext.setup({
onReady : function() {

Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'DayNumber', type: 'int'},
{name: 'PeriodNumber', type: 'string'},
{name: 'PeriodNumberSeq', type: 'string'},
{name: 'DefinitionPeriodNumber', type: 'string'},
{name: 'DefinitionTimeFrom', type: 'string'},
{name: 'DefinitionTimeTo', type: 'string'},
{name: 'ClassCode', type: 'string'},
{name: 'ClassDescription', type: 'string'},
{name: 'StaffID', type: 'string'},
{name: 'Room', type: 'string'},
]
});




var store = Ext.create('Ext.data.Store', {
model: 'User',
autoLoad:true,
proxy: {
type: 'jsonp',
url : 'https://intranet.trinity.vic.edu.au/timetable/getTimetable.asp?synID=300068&room=0&year=2011&term=4&day=8&callType=student'
}
});


listPanel = new Ext.List({
store: store,
id:'todaypanel',
itemSelector:'item',
itemTpl: '{ClassDescription} <div id="teacher">{Room}</div>',
});



panel = new Ext.Panel ({
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide',
items: [listPanel]
});
}
});


Matt

mitchellsimoens
18 Nov 2011, 3:21 PM
What is the response? Is it a plain JSON string or does it have the callback method like this:


someCallback({.....})

borden0108
18 Nov 2011, 6:08 PM
The Json does not have the call back. I don't have access to the server side is there a way to use jsonp without the callback or can I get the file then put it in the function?

mitchellsimoens
18 Nov 2011, 6:11 PM
It has to have the callback function. What it does is creates a script tag and loads the JSON that way but it has to be executed within that script tag... this is why there is a callback function.

borden0108
18 Nov 2011, 6:14 PM
Hmm is there another way to get the data? Into the list ?

mitchellsimoens
18 Nov 2011, 6:20 PM
Hmm is there another way to get the data? Into the list ?

Without a callback, no. It's the browser security that is stopping cross domain and ST1 doesn't have CORS support.

borden0108
18 Nov 2011, 6:29 PM
Could I get the data in in st2?

mitchellsimoens
18 Nov 2011, 6:32 PM
Could I get the data in in st2?

Ext JS 4's Ext.Ajax just got CORS support so it will probably be making it's way to ST2

borden0108
18 Nov 2011, 6:40 PM
I've heard that phone gap has CROS domain support through Ajax ?