Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / Connection.html
index fc4beaa..f5fb146 100644 (file)
@@ -1,11 +1,17 @@
-<html>\r
-<head>\r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js">(function(){\r
+<html>
+<head>
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+(function(){\r
     var BEFOREREQUEST = "beforerequest",\r
         REQUESTCOMPLETE = "requestcomplete",\r
         REQUESTEXCEPTION = "requestexception",\r
         Ext.data.Connection.superclass.constructor.call(this);\r
     };\r
 \r
-    // private\r
-    function handleResponse(response){\r
-        this.transId = false;\r
-        var options = response.argument.options;\r
-        response.argument = options ? options.argument : null;\r
-        this.fireEvent(REQUESTCOMPLETE, this, response, options);\r
-        if(options.success){\r
-            options.success.call(options.scope, response, options);\r
-        }\r
-        if(options.callback){\r
-            options.callback.call(options.scope, options, true, response);\r
-        }\r
-    }\r
-\r
-    // private\r
-    function handleFailure(response, e){\r
-        this.transId = false;\r
-        var options = response.argument.options;\r
-        response.argument = options ? options.argument : null;\r
-        this.fireEvent(REQUESTEXCEPTION, this, response, options, e);\r
-        if(options.failure){\r
-            options.failure.call(options.scope, response, options);\r
-        }\r
-        if(options.callback){\r
-            options.callback.call(options.scope, options, false, response);\r
-        }\r
-    }\r
-\r
-    // private\r
-    function doFormUpload(o, ps, url){\r
-        var id = Ext.id(),\r
-            doc = document,\r
-            frame = doc.createElement('iframe'),\r
-            form = Ext.getDom(o.form),\r
-            hiddens = [],\r
-            hd,\r
-            encoding = 'multipart/form-data',\r
-            buf = {\r
-                target: form.target,\r
-                method: form.method,\r
-                encoding: form.encoding,\r
-                enctype: form.enctype,\r
-                action: form.action\r
-            };\r
-            \r
-        Ext.apply(frame, {\r
-            id: id,\r
-            name: id,\r
-            className: 'x-hidden',\r
-            src: Ext.SSL_SECURE_URL // for IE\r
-        });     \r
-        doc.body.appendChild(frame);\r
-        \r
-        // This is required so that IE doesn't pop the response up in a new window.\r
-        if(Ext.isIE){\r
-           document.frames[id].name = id;\r
-        }\r
-        \r
-        Ext.apply(form, {\r
-            target: id,\r
-            method: POST,\r
-            enctype: encoding,\r
-            encoding: encoding,\r
-            action: url || buf.action\r
-        });\r
-        \r
-        // add dynamic params            \r
-        ps = Ext.urlDecode(ps, false);\r
-        for(var k in ps){\r
-            if(ps.hasOwnProperty(k)){\r
-                hd = doc.createElement('input');\r
-                hd.type = 'hidden';                    \r
-                hd.value = ps[hd.name = k];\r
-                form.appendChild(hd);\r
-                hiddens.push(hd);\r
-            }\r
-        }        \r
-\r
-        function cb(){\r
-            var me = this,\r
-                // bogus response object\r
-                r = {responseText : '',\r
-                     responseXML : null,\r
-                     argument : o.argument},\r
-                doc,\r
-                firstChild;\r
-\r
-            try{ \r
-                doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;\r
-                if(doc){\r
-                    if(doc.body){\r
-                        if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea                        \r
-                            r.responseText = firstChild.value;\r
-                        }else{\r
-                            r.responseText = doc.body.innerHTML;\r
-                        }\r
-                    }\r
-                    //in IE the document may still have a body even if returns XML.\r
-                    r.responseXML = doc.XMLDocument || doc;\r
-                }\r
-            }\r
-            catch(e) {}\r
-\r
-            Ext.EventManager.removeListener(frame, LOAD, cb, me);\r
-\r
-            me.fireEvent(REQUESTCOMPLETE, me, r, o);\r
-            \r
-            function runCallback(fn, scope, args){\r
-                if(Ext.isFunction(fn)){\r
-                    fn.apply(scope, args);\r
-                }\r
-            }\r
-\r
-            runCallback(o.success, o.scope, [r, o]);\r
-            runCallback(o.callback, o.scope, [o, true, r]);\r
-\r
-            if(!me.debugUploads){\r
-                setTimeout(function(){Ext.removeNode(frame);}, 100);\r
-            }\r
-        }\r
-\r
-        Ext.EventManager.on(frame, LOAD, cb, this);\r
-        form.submit();\r
-        \r
-        Ext.apply(form, buf);\r
-        Ext.each(hiddens, function(h) {\r
-            Ext.removeNode(h);\r
-        });\r
-    }\r
-\r
     Ext.extend(Ext.data.Connection, Ext.util.Observable, {\r
         <div id="cfg-Ext.data.Connection-url"></div>/**\r
          * @cfg {String} url (Optional) <p>The default URL to be used for requests to the server. Defaults to undefined.</p>\r
@@ -370,8 +246,8 @@ Ext.Ajax.request({
                 var p = o.params,\r
                     url = o.url || me.url,                \r
                     method,\r
-                    cb = {success: handleResponse,\r
-                          failure: handleFailure,\r
+                    cb = {success: me.handleResponse,\r
+                          failure: me.handleFailure,\r
                           scope: me,\r
                           argument: {options: o},\r
                           timeout : o.timeout || me.timeout\r
@@ -393,7 +269,7 @@ Ext.Ajax.request({
                 if((form = Ext.getDom(o.form))){\r
                     url = url || form.action;\r
                      if(o.isUpload || /multipart\/form-data/i.test(form.getAttribute("enctype"))) { \r
-                         return doFormUpload.call(me, o, p, url);\r
+                         return me.doFormUpload.call(me, o, p, url);\r
                      }\r
                     serForm = Ext.lib.Ajax.serializeForm(form);                    \r
                     p = p ? (p + '&' + serForm) : serForm;\r
@@ -439,6 +315,136 @@ Ext.Ajax.request({
             if(transId || this.isLoading()){\r
                 Ext.lib.Ajax.abort(transId || this.transId);\r
             }\r
+        },\r
+\r
+        // private\r
+        handleResponse : function(response){\r
+            this.transId = false;\r
+            var options = response.argument.options;\r
+            response.argument = options ? options.argument : null;\r
+            this.fireEvent(REQUESTCOMPLETE, this, response, options);\r
+            if(options.success){\r
+                options.success.call(options.scope, response, options);\r
+            }\r
+            if(options.callback){\r
+                options.callback.call(options.scope, options, true, response);\r
+            }\r
+        },\r
+\r
+        // private\r
+        handleFailure : function(response, e){\r
+            this.transId = false;\r
+            var options = response.argument.options;\r
+            response.argument = options ? options.argument : null;\r
+            this.fireEvent(REQUESTEXCEPTION, this, response, options, e);\r
+            if(options.failure){\r
+                options.failure.call(options.scope, response, options);\r
+            }\r
+            if(options.callback){\r
+                options.callback.call(options.scope, options, false, response);\r
+            }\r
+        },\r
+\r
+        // private\r
+        doFormUpload : function(o, ps, url){\r
+            var id = Ext.id(),\r
+                doc = document,\r
+                frame = doc.createElement('iframe'),\r
+                form = Ext.getDom(o.form),\r
+                hiddens = [],\r
+                hd,\r
+                encoding = 'multipart/form-data',\r
+                buf = {\r
+                    target: form.target,\r
+                    method: form.method,\r
+                    encoding: form.encoding,\r
+                    enctype: form.enctype,\r
+                    action: form.action\r
+                };\r
+\r
+            Ext.fly(frame).set({\r
+                id: id,\r
+                name: id,\r
+                cls: 'x-hidden',\r
+                src: Ext.SSL_SECURE_URL // for IE\r
+            });\r
+            doc.body.appendChild(frame);\r
+\r
+            // This is required so that IE doesn't pop the response up in a new window.\r
+            if(Ext.isIE){\r
+               document.frames[id].name = id;\r
+            }\r
+\r
+            Ext.fly(form).set({\r
+                target: id,\r
+                method: POST,\r
+                enctype: encoding,\r
+                encoding: encoding,\r
+                action: url || buf.action\r
+            });\r
+\r
+            // add dynamic params\r
+            Ext.iterate(Ext.urlDecode(ps, false), function(k, v){\r
+                hd = doc.createElement('input');\r
+                Ext.fly(hd).set({\r
+                    type: 'hidden',\r
+                    value: v,\r
+                    name: k\r
+                });\r
+                form.appendChild(hd);\r
+                hiddens.push(hd);\r
+            });\r
+\r
+            function cb(){\r
+                var me = this,\r
+                    // bogus response object\r
+                    r = {responseText : '',\r
+                         responseXML : null,\r
+                         argument : o.argument},\r
+                    doc,\r
+                    firstChild;\r
+\r
+                try{\r
+                    doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;\r
+                    if(doc){\r
+                        if(doc.body){\r
+                            if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea\r
+                                r.responseText = firstChild.value;\r
+                            }else{\r
+                                r.responseText = doc.body.innerHTML;\r
+                            }\r
+                        }\r
+                        //in IE the document may still have a body even if returns XML.\r
+                        r.responseXML = doc.XMLDocument || doc;\r
+                    }\r
+                }\r
+                catch(e) {}\r
+\r
+                Ext.EventManager.removeListener(frame, LOAD, cb, me);\r
+\r
+                me.fireEvent(REQUESTCOMPLETE, me, r, o);\r
+\r
+                function runCallback(fn, scope, args){\r
+                    if(Ext.isFunction(fn)){\r
+                        fn.apply(scope, args);\r
+                    }\r
+                }\r
+\r
+                runCallback(o.success, o.scope, [r, o]);\r
+                runCallback(o.callback, o.scope, [o, true, r]);\r
+\r
+                if(!me.debugUploads){\r
+                    setTimeout(function(){Ext.removeNode(frame);}, 100);\r
+                }\r
+            }\r
+\r
+            Ext.EventManager.on(frame, LOAD, cb, this);\r
+            form.submit();\r
+\r
+            Ext.fly(form).set(buf);\r
+            Ext.each(hiddens, function(h) {\r
+                Ext.removeNode(h);\r
+            });\r
         }\r
     });\r
 })();\r
@@ -574,6 +580,6 @@ Ext.Ajax = new Ext.data.Connection({
         return Ext.lib.Ajax.serializeForm(form);\r
     }\r
 });\r
-</pre>    \r
-</body>\r
+</pre>
+</body>
 </html>
\ No newline at end of file