1. #1
    Sencha Premium Member
    Join Date
    May 2007
    Location
    USA
    Posts
    73
    Vote Rating
    0
    notjoshing is on a distinguished road

      0  

    Default 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:

    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         '...'
        
    }
    }); 
    Running this in FF, I see this error in Firebug:
    Code:
    JSONPCallback is not defined
    [Break On This Error] JSONPCallback ( {"itemsList": {
    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.

    Any ideas on what might be wrong or how to troubleshoot/fix this?

    Thanks,

    Josh
    Using:
    ExtJS 2.2, 3.2, 4.0.7a
    WinXP SP3
    FF10,6; IE6; IE8; Safari

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,624
    Vote Rating
    331
    Answers
    550
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    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).

Thread Participants: 1