X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/docs/source/Connection.html diff --git a/docs/source/Connection.html b/docs/source/Connection.html index fc4beaa0..f5fb1469 100644 --- a/docs/source/Connection.html +++ b/docs/source/Connection.html @@ -1,11 +1,17 @@ - - - The source code - - - - -
(function(){
+
+
+  The source code
+    
+    
+
+
+    
/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+(function(){
     var BEFOREREQUEST = "beforerequest",
         REQUESTCOMPLETE = "requestcomplete",
         REQUESTEXCEPTION = "requestexception",
@@ -83,136 +89,6 @@
         Ext.data.Connection.superclass.constructor.call(this);
     };
 
-    // private
-    function handleResponse(response){
-        this.transId = false;
-        var options = response.argument.options;
-        response.argument = options ? options.argument : null;
-        this.fireEvent(REQUESTCOMPLETE, this, response, options);
-        if(options.success){
-            options.success.call(options.scope, response, options);
-        }
-        if(options.callback){
-            options.callback.call(options.scope, options, true, response);
-        }
-    }
-
-    // private
-    function handleFailure(response, e){
-        this.transId = false;
-        var options = response.argument.options;
-        response.argument = options ? options.argument : null;
-        this.fireEvent(REQUESTEXCEPTION, this, response, options, e);
-        if(options.failure){
-            options.failure.call(options.scope, response, options);
-        }
-        if(options.callback){
-            options.callback.call(options.scope, options, false, response);
-        }
-    }
-
-    // private
-    function doFormUpload(o, ps, url){
-        var id = Ext.id(),
-            doc = document,
-            frame = doc.createElement('iframe'),
-            form = Ext.getDom(o.form),
-            hiddens = [],
-            hd,
-            encoding = 'multipart/form-data',
-            buf = {
-                target: form.target,
-                method: form.method,
-                encoding: form.encoding,
-                enctype: form.enctype,
-                action: form.action
-            };
-            
-        Ext.apply(frame, {
-            id: id,
-            name: id,
-            className: 'x-hidden',
-            src: Ext.SSL_SECURE_URL // for IE
-        });     
-        doc.body.appendChild(frame);
-        
-        // This is required so that IE doesn't pop the response up in a new window.
-        if(Ext.isIE){
-           document.frames[id].name = id;
-        }
-        
-        Ext.apply(form, {
-            target: id,
-            method: POST,
-            enctype: encoding,
-            encoding: encoding,
-            action: url || buf.action
-        });
-        
-        // add dynamic params            
-        ps = Ext.urlDecode(ps, false);
-        for(var k in ps){
-            if(ps.hasOwnProperty(k)){
-                hd = doc.createElement('input');
-                hd.type = 'hidden';                    
-                hd.value = ps[hd.name = k];
-                form.appendChild(hd);
-                hiddens.push(hd);
-            }
-        }        
-
-        function cb(){
-            var me = this,
-                // bogus response object
-                r = {responseText : '',
-                     responseXML : null,
-                     argument : o.argument},
-                doc,
-                firstChild;
-
-            try{ 
-                doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
-                if(doc){
-                    if(doc.body){
-                        if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea                        
-                            r.responseText = firstChild.value;
-                        }else{
-                            r.responseText = doc.body.innerHTML;
-                        }
-                    }
-                    //in IE the document may still have a body even if returns XML.
-                    r.responseXML = doc.XMLDocument || doc;
-                }
-            }
-            catch(e) {}
-
-            Ext.EventManager.removeListener(frame, LOAD, cb, me);
-
-            me.fireEvent(REQUESTCOMPLETE, me, r, o);
-            
-            function runCallback(fn, scope, args){
-                if(Ext.isFunction(fn)){
-                    fn.apply(scope, args);
-                }
-            }
-
-            runCallback(o.success, o.scope, [r, o]);
-            runCallback(o.callback, o.scope, [o, true, r]);
-
-            if(!me.debugUploads){
-                setTimeout(function(){Ext.removeNode(frame);}, 100);
-            }
-        }
-
-        Ext.EventManager.on(frame, LOAD, cb, this);
-        form.submit();
-        
-        Ext.apply(form, buf);
-        Ext.each(hiddens, function(h) {
-            Ext.removeNode(h);
-        });
-    }
-
     Ext.extend(Ext.data.Connection, Ext.util.Observable, {
         
/** * @cfg {String} url (Optional)

The default URL to be used for requests to the server. Defaults to undefined.

@@ -370,8 +246,8 @@ Ext.Ajax.request({ var p = o.params, url = o.url || me.url, method, - cb = {success: handleResponse, - failure: handleFailure, + cb = {success: me.handleResponse, + failure: me.handleFailure, scope: me, argument: {options: o}, timeout : o.timeout || me.timeout @@ -393,7 +269,7 @@ Ext.Ajax.request({ if((form = Ext.getDom(o.form))){ url = url || form.action; if(o.isUpload || /multipart\/form-data/i.test(form.getAttribute("enctype"))) { - return doFormUpload.call(me, o, p, url); + return me.doFormUpload.call(me, o, p, url); } serForm = Ext.lib.Ajax.serializeForm(form); p = p ? (p + '&' + serForm) : serForm; @@ -439,6 +315,136 @@ Ext.Ajax.request({ if(transId || this.isLoading()){ Ext.lib.Ajax.abort(transId || this.transId); } + }, + + // private + handleResponse : function(response){ + this.transId = false; + var options = response.argument.options; + response.argument = options ? options.argument : null; + this.fireEvent(REQUESTCOMPLETE, this, response, options); + if(options.success){ + options.success.call(options.scope, response, options); + } + if(options.callback){ + options.callback.call(options.scope, options, true, response); + } + }, + + // private + handleFailure : function(response, e){ + this.transId = false; + var options = response.argument.options; + response.argument = options ? options.argument : null; + this.fireEvent(REQUESTEXCEPTION, this, response, options, e); + if(options.failure){ + options.failure.call(options.scope, response, options); + } + if(options.callback){ + options.callback.call(options.scope, options, false, response); + } + }, + + // private + doFormUpload : function(o, ps, url){ + var id = Ext.id(), + doc = document, + frame = doc.createElement('iframe'), + form = Ext.getDom(o.form), + hiddens = [], + hd, + encoding = 'multipart/form-data', + buf = { + target: form.target, + method: form.method, + encoding: form.encoding, + enctype: form.enctype, + action: form.action + }; + + Ext.fly(frame).set({ + id: id, + name: id, + cls: 'x-hidden', + src: Ext.SSL_SECURE_URL // for IE + }); + doc.body.appendChild(frame); + + // This is required so that IE doesn't pop the response up in a new window. + if(Ext.isIE){ + document.frames[id].name = id; + } + + Ext.fly(form).set({ + target: id, + method: POST, + enctype: encoding, + encoding: encoding, + action: url || buf.action + }); + + // add dynamic params + Ext.iterate(Ext.urlDecode(ps, false), function(k, v){ + hd = doc.createElement('input'); + Ext.fly(hd).set({ + type: 'hidden', + value: v, + name: k + }); + form.appendChild(hd); + hiddens.push(hd); + }); + + function cb(){ + var me = this, + // bogus response object + r = {responseText : '', + responseXML : null, + argument : o.argument}, + doc, + firstChild; + + try{ + doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document; + if(doc){ + if(doc.body){ + if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea + r.responseText = firstChild.value; + }else{ + r.responseText = doc.body.innerHTML; + } + } + //in IE the document may still have a body even if returns XML. + r.responseXML = doc.XMLDocument || doc; + } + } + catch(e) {} + + Ext.EventManager.removeListener(frame, LOAD, cb, me); + + me.fireEvent(REQUESTCOMPLETE, me, r, o); + + function runCallback(fn, scope, args){ + if(Ext.isFunction(fn)){ + fn.apply(scope, args); + } + } + + runCallback(o.success, o.scope, [r, o]); + runCallback(o.callback, o.scope, [o, true, r]); + + if(!me.debugUploads){ + setTimeout(function(){Ext.removeNode(frame);}, 100); + } + } + + Ext.EventManager.on(frame, LOAD, cb, this); + form.submit(); + + Ext.fly(form).set(buf); + Ext.each(hiddens, function(h) { + Ext.removeNode(h); + }); } }); })(); @@ -574,6 +580,6 @@ Ext.Ajax = new Ext.data.Connection({ return Ext.lib.Ajax.serializeForm(form); } }); -
- +
+ \ No newline at end of file