PDA

View Full Version : ScriptTag and server-defined callback key.. help!



rgporter
24 Jan 2011, 10:09 AM
Hi - I'm having trouble finding a way around the fact that the Flickr API returns it's own JSONP callback key "jsonFlickrFeed" rather than accepting the scripttag's predefined callback function. So it starts with
jsonFlickrFeed({...
no matter what. I've tried using the callbackKey parameter but it doesn't seem to work, and I always generate a "Can't find variable" error.



var flickrStore = new Ext.data.Store({
model: 'FlickrPhotos',
proxy: {

type: 'scripttag',
url: this.url,
extraParams: {
format: 'json'
},
reader: {
type: 'json',
root: 'items'
},
callbackKey: 'jsonFlickrFeed'
},
autoLoad: true
});

doesn't work. Help!

rgporter
24 Jan 2011, 12:41 PM
OK, found a workaround of sorts. Flickr does give the option to give your own callback fn. For those who encounter this issue with Flickr (or other services that might work this way), the proxy needs to call


callbackParam: 'jsoncallback'

Where 'jsoncallback' is the param the service uses to feed in custom callback fn names.

amussini@gmail.com
15 Feb 2012, 3:34 AM
Hi man, I'm looking for something that you, probably, solved.

My app.js

new Ext.Application({ name: "NestedListDemo",


launch: function() {
this.views.viewport = new this.views.Viewport();
}
});

My Viewport.js

NestedListDemo.views.Viewport = Ext.extend(Ext.NestedList, { fullscreen: true,
title: 'Music',
store: NestedListDemo.music_store
});

my music_store.js

function someCallback(data){
// don't know what to do
}


NestedListDemo.music_store = new Ext.data.TreeStore({
model: 'ListItem',
autoSync: true,
autoSave: true,
id: 'ListStore',
proxy:{

type: 'scripttag',
url: 'http://mydomain../data/tracks.json' ,
callbackParam: 'jsoncallback',
callbackKey: 'someCallback',
extraParams: {
format: 'json'
},
reader: {
type: 'tree',
root: "items"
},
writer: {
type: 'json'
}


},
autoLoad: true
});




my json file

someCallback({ "items": [
{
"model": "Genre",
"items": [
{
"model": "Artist",
"items": [
{
"model": "Album",
"items": [
{
"model": "Track",
"duration": 96,
"text": "Introduction",
"items": [


],
"info": "",
"leaf": true
},.......



Have you any idea how to populate my damn NestedList AFTER jsonp call?
My NestedList remains absolutely empty, nothing loads anything....

Best regards