3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
9 Ext.ux.JSONP = (function(){
12 _nextRequest = function() {
15 _current = _queue.shift();
16 _current.script.src = _current.url + '?' + _current.params;
17 document.getElementsByTagName('head')[0].appendChild(_current.script);
22 request: function(url, o) {
28 o.params = o.params || {};
30 o.params[o.callbackKey] = 'Ext.ux.JSONP.callback';
32 var params = Ext.urlEncode(o.params);
34 var script = document.createElement('script');
35 script.type = 'text/javascript';
39 Ext.fly(script).on('readystatechange', function() {
40 if(script.readyState == 'complete') {
41 var data = script.innerHTML;
43 me.callback(Ext.decode(data));
49 Ext.fly(script).on('load', function() {
50 var data = script.innerHTML;
52 me.callback(Ext.decode(data));
61 callback: o.callback || function(){},
62 scope: o.scope || window,
63 params: params || null
71 callback: function(json) {
72 _current.callback.apply(_current.scope, [json]);
73 Ext.fly(_current.script).removeAllListeners();
74 document.getElementsByTagName('head')[0].removeChild(_current.script);