Ticket #6526: staticCallback.diff
| File staticCallback.diff, 1.8 kB (added by kriszyp, 9 months ago) |
|---|
-
script.js
74 74 var ioArgs = dfd.ioArgs; 75 75 ioArgs.id = dojo._scopeName + "IoScript" + (this._counter++); 76 76 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 }; 78 85 //Special setup for jsonp case 79 86 if(args.callbackParamName){ 80 87 //Add the jsonp parameter. … … 89 96 90 97 //Setup the Deferred to have the jsonp callback. 91 98 ioArgs.canDelete = true; 92 dfd._jsonpCallback = this._jsonpCallback;99 dfd._jsonpCallback = jsonpCallback; 93 100 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; 94 109 } 95 110 return dfd; // dojo.Deferred 96 111 }, … … 196 211 } 197 212 }, 198 213 199 _jsonpCallback: function(/*JSON Object*/json){200 //summary:201 // generic handler for jsonp callback. A pointer to this function202 // is used for all jsonp callbacks. NOTE: the "this" in this203 // function will be the Deferred object that represents the script204 // request.205 this.ioArgs.json = json;206 }207 214 }