Ticket #6526: staticCallback.diff

File staticCallback.diff, 1.8 kB (added by kriszyp, 9 months ago)

Patch

  • script.js

     
    7474                var ioArgs = dfd.ioArgs; 
    7575                ioArgs.id = dojo._scopeName + "IoScript" + (this._counter++); 
    7676                ioArgs.canDelete = false; 
    77  
     77                var jsonpCallback = function(/*JSON Object*/json){ 
     78                        //summary:  
     79                        //              generic handler for jsonp callback. A pointer to this function 
     80                        //              is used for all jsonp callbacks.  NOTE: the "this" in this 
     81                        //              function will be the Deferred object that represents the script 
     82                        //              request. 
     83                        dfd.ioArgs.json = json; 
     84                }; 
    7885                //Special setup for jsonp case 
    7986                if(args.callbackParamName){ 
    8087                        //Add the jsonp parameter. 
     
    8996 
    9097                        //Setup the Deferred to have the jsonp callback. 
    9198                        ioArgs.canDelete = true; 
    92                         dfd._jsonpCallback = this._jsonpCallback; 
     99                        dfd._jsonpCallback = jsonpCallback; 
    93100                        this["jsonp_" + ioArgs.id] = dfd; 
     101                } else if(args.staticCallback){  
     102                        // we use the static callback method, where the callback name is the URL of the resource 
     103                        // see http://www.json.com/2008/04/01/static-json-with-callback/ 
     104                        var url = typeof args.staticCallback == 'string' ?  
     105                                        args.staticCallback : new dojo._Url(location, ioArgs.url) + ''; // get the absolute url of the resource 
     106 
     107                        // we may want to use dojo.connect here so multiple requests can be made for the same resource 
     108                        dojo.global[url] = jsonpCallback;                        
    94109                } 
    95110                return dfd; // dojo.Deferred 
    96111        }, 
     
    196211                } 
    197212        }, 
    198213 
    199         _jsonpCallback: function(/*JSON Object*/json){ 
    200                 //summary:  
    201                 //              generic handler for jsonp callback. A pointer to this function 
    202                 //              is used for all jsonp callbacks.  NOTE: the "this" in this 
    203                 //              function will be the Deferred object that represents the script 
    204                 //              request. 
    205                 this.ioArgs.json = json; 
    206         } 
    207214}