-
11 Oct 2011 11:26 AM #1
Unanswered: How do I get jsonp proxy callbacks to work?
Unanswered: How do I get jsonp proxy callbacks to work?
Using Ext 4.0.2a I'm having a problem adding a callback to my jsonp proxy:
Running this in FF, I see this error in Firebug:PHP Code:Ext.define('pipeline.store.PipelineSearch', {
extend : 'Ext.data.Store',
listeners : {
exception : function() {
Ext.Msg.alert('Error',arguments);
}
},
model : 'pipeline.model.PipelineSearch',
proxy : {
type : 'jsonp',
callbackKey : 'test',
callback : function(data) {
console.log('data='+data);
},
// there seems to be a bug currently causing a reader config to not be
// instanciated into a reader object. I therefore instanciate a
// reader object rather than reader : { root: ...}
reader : new Ext.data.reader.Json({
root : 'itemsList.item',
model : 'pipeline.model.PipelineSearch'
}),
root : 'itemsList.item',
url : '...'
}
});
Removing the callbackKey allows the proxy to work normally, but without the callback. I tried creating a JSONPCallback function to see what would happen. It gets called, but the store never receives the data.Code:JSONPCallback is not defined [Break On This Error] JSONPCallback ( {"itemsList": {
Any ideas on what might be wrong or how to troubleshoot/fix this?
Thanks,
JoshUsing:
ExtJS 2.2, 3.2, 4.0.7a
WinXP SP3
FF10,6; IE6; IE8; Safari
-
11 Oct 2011 1:46 PM #2
I'm confused about what you're trying to do.
As far as I can tell, the JSON-P proxy doesn't support a callback option.
In a JSON-P context, the 'callback' usually refers to the function used to wrap the data. It's a fundamental part of the mechanism used to communicate between the server and client, not a custom function you can provide. If you're unclear about how this works I'd suggest reading the introduction here:
http://docs.sencha.com/ext-js/4-0/#!...ta.proxy.JsonP
The callbackKey must use the same value that the server is expecting. You can't just set it to an arbitrary value like test. It specifies the name of a request parameter. This request parameter is used to tell the server the name of the callback function. If you use the wrong value then the server will probably just use a default function name (which seems to be JSONPCallback in your example).


Reply With Quote