PDA

View Full Version : [Question] using JsonStore's proxy for cross domain



ultrakyo
26 Jan 2012, 8:09 PM
var store = new Ext.data.JsonStore({
root: 'topics',
totalProperty: 'totalCount',
idProperty: 'threadid',
remoteSort: true,


fields: [
'title', 'forumtitle', 'forumid', 'author',
{name: 'replycount', type: 'int'},
{name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
'lastposter', 'excerpt'
],


// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.ScriptTagProxy({
url: 'http://extjs.com/forum/topics-browse-remote.php'
})
});

I tried to modify and use the above code for cross domain in my project.

But it seems that proxy does not get data properly.

console.log(store); shows data array[0].

Question
1. Is there other properties/handler I should additionally work on?

2. Is there other ways to use proxy for cross domain other than above method?

Thank you.

vadimv
26 Jan 2012, 11:35 PM
For cross domain use Ext.data.Store with proxy "jsonp" type. Should look like:


var store =Ext.create (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-create)('Ext.data.Store (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store)',{
model:'User',
proxy:{
type:'jsonp',
url :'http://domainB.com/users'
}
});

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.JsonP