PDA

View Full Version : JsonP store and trouble with reader



ByteLess
23 Apr 2014, 3:23 PM
Having some issues with loading data in my store using JsonP.

I have a facebook page which I need to load my json data from.
https://www.facebook.com/feeds/page.php?id=6815841748&format=json

Every time it error out and not able to load my data. I am not sure what is that I am not doing right.

my codes are as follows.


Ext.define('myApp.store.MyFeedStore', { extend: 'Ext.data.Store',


requires: [
'myApp.model.MyFeed',
'Ext.data.proxy.JsonP',
'Ext.data.reader.Json'
],


config: {
autoLoad: true,
model: 'myApp.model.MyFeed',
storeId: 'MyFeedStore',
proxy: {
type: 'jsonp',
url: 'https://www.facebook.com/feeds/page.php?id=6815841748&format=json',
callbackKey: 'jsoncallback',
reader: {
type: 'json',
record: 'entries'
}
}
}
});

evant
23 Apr 2014, 3:26 PM
Would suggest you read the introductory docs about how the jsonp proxy works, it's quite detailed and explains how it all works. After that you'll see why it doesn't work.

ByteLess
24 Apr 2014, 6:03 AM
Would suggest you read the introductory docs about how the jsonp proxy works, it's quite detailed and explains how it all works. After that you'll see why it doesn't work.

Just to clear.
I cannot use the JsonP with my store and proxy. I have to make a call like below?

Ext.data.JsonP.request({ url: 'http://example.com/script.php',
callbackKey: 'callback',
params: {
data: Ext.encode(values)
},
success : function(response) {
console.log("Spiffing, everything worked");
// success property
console.log(response.success);
// result property
console.log(response.result);
},
failure: function(response) {
console.log(response);
Ext.Msg.alert('Error', 'Please try again.', Ext.emptyFn);
}
});

ByteLess
24 Apr 2014, 10:10 AM
Would suggest you read the introductory docs about how the jsonp proxy works, it's quite detailed and explains how it all works. After that you'll see why it doesn't work.

Still don't understand how to use the JsonP after reading docs.

Can someone just give me a hint what I am doing wrong,

All I want is to load the json data from the url to the store.

ByteLess
24 Apr 2014, 10:43 AM
Is this breaking because the return result from FB is not Ext.data.JsonP.callback({ "data": { .....??

evant
24 Apr 2014, 4:29 PM
Yes, that's right. That's how JSONP works, it needs to call the callback function passed as part of the URL. Otherwise you don't know when it's complete.