Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / Connection.html
1 <html>\r
2 <head>\r
3   <title>The source code</title>\r
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
6 </head>\r
7 <body  onload="prettyPrint();">\r
8     <pre class="prettyprint lang-js">(function(){\r
9     var BEFOREREQUEST = "beforerequest",\r
10         REQUESTCOMPLETE = "requestcomplete",\r
11         REQUESTEXCEPTION = "requestexception",\r
12         UNDEFINED = undefined,\r
13         LOAD = 'load',\r
14         POST = 'POST',\r
15         GET = 'GET',\r
16         WINDOW = window;\r
17     \r
18     <div id="cls-Ext.data.Connection"></div>/**\r
19      * @class Ext.data.Connection\r
20      * @extends Ext.util.Observable\r
21      * <p>The class encapsulates a connection to the page's originating domain, allowing requests to be made\r
22      * either to a configured URL, or to a URL specified at request time.</p>\r
23      * <p>Requests made by this class are asynchronous, and will return immediately. No data from\r
24      * the server will be available to the statement immediately following the {@link #request} call.\r
25      * To process returned data, use a\r
26      * <a href="#request-option-success" ext:member="request-option-success" ext:cls="Ext.data.Connection">success callback</a>\r
27      * in the request options object,\r
28      * or an {@link #requestcomplete event listener}.</p>\r
29      * <p><h3>File Uploads</h3><a href="#request-option-isUpload" ext:member="request-option-isUpload" ext:cls="Ext.data.Connection">File uploads</a> are not performed using normal "Ajax" techniques, that\r
30      * is they are <b>not</b> performed using XMLHttpRequests. Instead the form is submitted in the standard\r
31      * manner with the DOM <tt>&lt;form></tt> element temporarily modified to have its\r
32      * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer\r
33      * to a dynamically generated, hidden <tt>&lt;iframe></tt> which is inserted into the document\r
34      * but removed after the return data has been gathered.</p>\r
35      * <p>The server response is parsed by the browser to create the document for the IFRAME. If the\r
36      * server is using JSON to send the return object, then the\r
37      * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> header\r
38      * must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p>\r
39      * <p>Characters which are significant to an HTML parser must be sent as HTML entities, so encode\r
40      * "&lt;" as "&amp;lt;", "&amp;" as "&amp;amp;" etc.</p>\r
41      * <p>The response text is retrieved from the document, and a fake XMLHttpRequest object\r
42      * is created containing a <tt>responseText</tt> property in order to conform to the\r
43      * requirements of event handlers and callbacks.</p>\r
44      * <p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>\r
45      * and some server technologies (notably JEE) may require some custom processing in order to\r
46      * retrieve parameter names and parameter values from the packet content.</p>\r
47      * @constructor\r
48      * @param {Object} config a configuration object.\r
49      */\r
50     Ext.data.Connection = function(config){    \r
51         Ext.apply(this, config);\r
52         this.addEvents(\r
53             <div id="event-Ext.data.Connection-beforerequest"></div>/**\r
54              * @event beforerequest\r
55              * Fires before a network request is made to retrieve a data object.\r
56              * @param {Connection} conn This Connection object.\r
57              * @param {Object} options The options config object passed to the {@link #request} method.\r
58              */\r
59             BEFOREREQUEST,\r
60             <div id="event-Ext.data.Connection-requestcomplete"></div>/**\r
61              * @event requestcomplete\r
62              * Fires if the request was successfully completed.\r
63              * @param {Connection} conn This Connection object.\r
64              * @param {Object} response The XHR object containing the response data.\r
65              * See <a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a>\r
66              * for details.\r
67              * @param {Object} options The options config object passed to the {@link #request} method.\r
68              */\r
69             REQUESTCOMPLETE,\r
70             <div id="event-Ext.data.Connection-requestexception"></div>/**\r
71              * @event requestexception\r
72              * Fires if an error HTTP status was returned from the server.\r
73              * See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP Status Code Definitions</a>\r
74              * for details of HTTP status codes.\r
75              * @param {Connection} conn This Connection object.\r
76              * @param {Object} response The XHR object containing the response data.\r
77              * See <a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a>\r
78              * for details.\r
79              * @param {Object} options The options config object passed to the {@link #request} method.\r
80              */\r
81             REQUESTEXCEPTION\r
82         );\r
83         Ext.data.Connection.superclass.constructor.call(this);\r
84     };\r
85 \r
86     // private\r
87     function handleResponse(response){\r
88         this.transId = false;\r
89         var options = response.argument.options;\r
90         response.argument = options ? options.argument : null;\r
91         this.fireEvent(REQUESTCOMPLETE, this, response, options);\r
92         if(options.success){\r
93             options.success.call(options.scope, response, options);\r
94         }\r
95         if(options.callback){\r
96             options.callback.call(options.scope, options, true, response);\r
97         }\r
98     }\r
99 \r
100     // private\r
101     function handleFailure(response, e){\r
102         this.transId = false;\r
103         var options = response.argument.options;\r
104         response.argument = options ? options.argument : null;\r
105         this.fireEvent(REQUESTEXCEPTION, this, response, options, e);\r
106         if(options.failure){\r
107             options.failure.call(options.scope, response, options);\r
108         }\r
109         if(options.callback){\r
110             options.callback.call(options.scope, options, false, response);\r
111         }\r
112     }\r
113 \r
114     // private\r
115     function doFormUpload(o, ps, url){\r
116         var id = Ext.id(),\r
117             doc = document,\r
118             frame = doc.createElement('iframe'),\r
119             form = Ext.getDom(o.form),\r
120             hiddens = [],\r
121             hd,\r
122             encoding = 'multipart/form-data',\r
123             buf = {\r
124                 target: form.target,\r
125                 method: form.method,\r
126                 encoding: form.encoding,\r
127                 enctype: form.enctype,\r
128                 action: form.action\r
129             };\r
130             \r
131         Ext.apply(frame, {\r
132             id: id,\r
133             name: id,\r
134             className: 'x-hidden',\r
135             src: Ext.SSL_SECURE_URL // for IE\r
136         });     \r
137         doc.body.appendChild(frame);\r
138         \r
139         // This is required so that IE doesn't pop the response up in a new window.\r
140         if(Ext.isIE){\r
141            document.frames[id].name = id;\r
142         }\r
143         \r
144         Ext.apply(form, {\r
145             target: id,\r
146             method: POST,\r
147             enctype: encoding,\r
148             encoding: encoding,\r
149             action: url || buf.action\r
150         });\r
151         \r
152         // add dynamic params            \r
153         ps = Ext.urlDecode(ps, false);\r
154         for(var k in ps){\r
155             if(ps.hasOwnProperty(k)){\r
156                 hd = doc.createElement('input');\r
157                 hd.type = 'hidden';                    \r
158                 hd.value = ps[hd.name = k];\r
159                 form.appendChild(hd);\r
160                 hiddens.push(hd);\r
161             }\r
162         }        \r
163 \r
164         function cb(){\r
165             var me = this,\r
166                 // bogus response object\r
167                 r = {responseText : '',\r
168                      responseXML : null,\r
169                      argument : o.argument},\r
170                 doc,\r
171                 firstChild;\r
172 \r
173             try{ \r
174                 doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;\r
175                 if(doc){\r
176                     if(doc.body){\r
177                         if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea                        \r
178                             r.responseText = firstChild.value;\r
179                         }else{\r
180                             r.responseText = doc.body.innerHTML;\r
181                         }\r
182                     }\r
183                     //in IE the document may still have a body even if returns XML.\r
184                     r.responseXML = doc.XMLDocument || doc;\r
185                 }\r
186             }\r
187             catch(e) {}\r
188 \r
189             Ext.EventManager.removeListener(frame, LOAD, cb, me);\r
190 \r
191             me.fireEvent(REQUESTCOMPLETE, me, r, o);\r
192             \r
193             function runCallback(fn, scope, args){\r
194                 if(Ext.isFunction(fn)){\r
195                     fn.apply(scope, args);\r
196                 }\r
197             }\r
198 \r
199             runCallback(o.success, o.scope, [r, o]);\r
200             runCallback(o.callback, o.scope, [o, true, r]);\r
201 \r
202             if(!me.debugUploads){\r
203                 setTimeout(function(){Ext.removeNode(frame);}, 100);\r
204             }\r
205         }\r
206 \r
207         Ext.EventManager.on(frame, LOAD, cb, this);\r
208         form.submit();\r
209         \r
210         Ext.apply(form, buf);\r
211         Ext.each(hiddens, function(h) {\r
212             Ext.removeNode(h);\r
213         });\r
214     }\r
215 \r
216     Ext.extend(Ext.data.Connection, Ext.util.Observable, {\r
217         <div id="cfg-Ext.data.Connection-url"></div>/**\r
218          * @cfg {String} url (Optional) <p>The default URL to be used for requests to the server. Defaults to undefined.</p>\r
219          * <p>The <code>url</code> config may be a function which <i>returns</i> the URL to use for the Ajax request. The scope\r
220          * (<code><b>this</b></code> reference) of the function is the <code>scope</code> option passed to the {@link #request} method.</p>\r
221          */\r
222         <div id="cfg-Ext.data.Connection-extraParams"></div>/**\r
223          * @cfg {Object} extraParams (Optional) An object containing properties which are used as\r
224          * extra parameters to each request made by this object. (defaults to undefined)\r
225          */\r
226         <div id="cfg-Ext.data.Connection-defaultHeaders"></div>/**\r
227          * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added\r
228          *  to each request made by this object. (defaults to undefined)\r
229          */\r
230         <div id="cfg-Ext.data.Connection-method"></div>/**\r
231          * @cfg {String} method (Optional) The default HTTP method to be used for requests.\r
232          * (defaults to undefined; if not set, but {@link #request} params are present, POST will be used;\r
233          * otherwise, GET will be used.)\r
234          */\r
235         <div id="cfg-Ext.data.Connection-timeout"></div>/**\r
236          * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)\r
237          */\r
238         timeout : 30000,\r
239         <div id="cfg-Ext.data.Connection-autoAbort"></div>/**\r
240          * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)\r
241          * @type Boolean\r
242          */\r
243         autoAbort:false,\r
244     \r
245         <div id="cfg-Ext.data.Connection-disableCaching"></div>/**\r
246          * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)\r
247          * @type Boolean\r
248          */\r
249         disableCaching: true,\r
250         \r
251         <div id="cfg-Ext.data.Connection-disableCachingParam"></div>/**\r
252          * @cfg {String} disableCachingParam (Optional) Change the parameter which is sent went disabling caching\r
253          * through a cache buster. Defaults to '_dc'\r
254          * @type String\r
255          */\r
256         disableCachingParam: '_dc',\r
257         \r
258         <div id="method-Ext.data.Connection-request"></div>/**\r
259          * <p>Sends an HTTP request to a remote server.</p>\r
260          * <p><b>Important:</b> Ajax server requests are asynchronous, and this call will\r
261          * return before the response has been received. Process any returned data\r
262          * in a callback function.</p>\r
263          * <pre><code>\r
264 Ext.Ajax.request({\r
265    url: 'ajax_demo/sample.json',\r
266    success: function(response, opts) {\r
267       var obj = Ext.decode(response.responseText);\r
268       console.dir(obj);\r
269    },\r
270    failure: function(response, opts) {\r
271       console.log('server-side failure with status code ' + response.status);\r
272    }\r
273 });\r
274          * </code></pre>\r
275          * <p>To execute a callback function in the correct scope, use the <tt>scope</tt> option.</p>\r
276          * @param {Object} options An object which may contain the following properties:<ul>\r
277          * <li><b>url</b> : String/Function (Optional)<div class="sub-desc">The URL to\r
278          * which to send the request, or a function to call which returns a URL string. The scope of the\r
279          * function is specified by the <tt>scope</tt> option. Defaults to the configured\r
280          * <tt>{@link #url}</tt>.</div></li>\r
281          * <li><b>params</b> : Object/String/Function (Optional)<div class="sub-desc">\r
282          * An object containing properties which are used as parameters to the\r
283          * request, a url encoded string or a function to call to get either. The scope of the function\r
284          * is specified by the <tt>scope</tt> option.</div></li>\r
285          * <li><b>method</b> : String (Optional)<div class="sub-desc">The HTTP method to use\r
286          * for the request. Defaults to the configured method, or if no method was configured,\r
287          * "GET" if no parameters are being sent, and "POST" if parameters are being sent.  Note that\r
288          * the method name is case-sensitive and should be all caps.</div></li>\r
289          * <li><b>callback</b> : Function (Optional)<div class="sub-desc">The\r
290          * function to be called upon receipt of the HTTP response. The callback is\r
291          * called regardless of success or failure and is passed the following\r
292          * parameters:<ul>\r
293          * <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>\r
294          * <li><b>success</b> : Boolean<div class="sub-desc">True if the request succeeded.</div></li>\r
295          * <li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data. \r
296          * See <a href="http://www.w3.org/TR/XMLHttpRequest/">http://www.w3.org/TR/XMLHttpRequest/</a> for details about \r
297          * accessing elements of the response.</div></li>\r
298          * </ul></div></li>\r
299          * <li><a id="request-option-success"></a><b>success</b> : Function (Optional)<div class="sub-desc">The function\r
300          * to be called upon success of the request. The callback is passed the following\r
301          * parameters:<ul>\r
302          * <li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data.</div></li>\r
303          * <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>\r
304          * </ul></div></li>\r
305          * <li><b>failure</b> : Function (Optional)<div class="sub-desc">The function\r
306          * to be called upon failure of the request. The callback is passed the\r
307          * following parameters:<ul>\r
308          * <li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data.</div></li>\r
309          * <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>\r
310          * </ul></div></li>\r
311          * <li><b>scope</b> : Object (Optional)<div class="sub-desc">The scope in\r
312          * which to execute the callbacks: The "this" object for the callback function. If the <tt>url</tt>, or <tt>params</tt> options were\r
313          * specified as functions from which to draw values, then this also serves as the scope for those function calls.\r
314          * Defaults to the browser window.</div></li>\r
315          * <li><b>timeout</b> : Number (Optional)<div class="sub-desc">The timeout in milliseconds to be used for this request. Defaults to 30 seconds.</div></li>\r
316          * <li><b>form</b> : Element/HTMLElement/String (Optional)<div class="sub-desc">The <tt>&lt;form&gt;</tt>\r
317          * Element or the id of the <tt>&lt;form&gt;</tt> to pull parameters from.</div></li>\r
318          * <li><a id="request-option-isUpload"></a><b>isUpload</b> : Boolean (Optional)<div class="sub-desc"><b>Only meaningful when used \r
319          * with the <tt>form</tt> option</b>.\r
320          * <p>True if the form object is a file upload (will be set automatically if the form was\r
321          * configured with <b><tt>enctype</tt></b> "multipart/form-data").</p>\r
322          * <p>File uploads are not performed using normal "Ajax" techniques, that is they are <b>not</b>\r
323          * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the\r
324          * DOM <tt>&lt;form></tt> element temporarily modified to have its\r
325          * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer\r
326          * to a dynamically generated, hidden <tt>&lt;iframe></tt> which is inserted into the document\r
327          * but removed after the return data has been gathered.</p>\r
328          * <p>The server response is parsed by the browser to create the document for the IFRAME. If the\r
329          * server is using JSON to send the return object, then the\r
330          * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> header\r
331          * must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p>\r
332          * <p>The response text is retrieved from the document, and a fake XMLHttpRequest object\r
333          * is created containing a <tt>responseText</tt> property in order to conform to the\r
334          * requirements of event handlers and callbacks.</p>\r
335          * <p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>\r
336          * and some server technologies (notably JEE) may require some custom processing in order to\r
337          * retrieve parameter names and parameter values from the packet content.</p>\r
338          * </div></li>\r
339          * <li><b>headers</b> : Object (Optional)<div class="sub-desc">Request\r
340          * headers to set for the request.</div></li>\r
341          * <li><b>xmlData</b> : Object (Optional)<div class="sub-desc">XML document\r
342          * to use for the post. Note: This will be used instead of params for the post\r
343          * data. Any params will be appended to the URL.</div></li>\r
344          * <li><b>jsonData</b> : Object/String (Optional)<div class="sub-desc">JSON\r
345          * data to use as the post. Note: This will be used instead of params for the post\r
346          * data. Any params will be appended to the URL.</div></li>\r
347          * <li><b>disableCaching</b> : Boolean (Optional)<div class="sub-desc">True\r
348          * to add a unique cache-buster param to GET requests.</div></li>\r
349          * </ul></p>\r
350          * <p>The options object may also contain any other property which might be needed to perform\r
351          * postprocessing in a callback because it is passed to callback functions.</p>\r
352          * @return {Number} transactionId The id of the server transaction. This may be used\r
353          * to cancel the request.\r
354          */\r
355         request : function(o){\r
356             var me = this;\r
357             if(me.fireEvent(BEFOREREQUEST, me, o)){\r
358                 if (o.el) {\r
359                     if(!Ext.isEmpty(o.indicatorText)){\r
360                         me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";\r
361                     }\r
362                     if(me.indicatorText) {\r
363                         Ext.getDom(o.el).innerHTML = me.indicatorText;                        \r
364                     }\r
365                     o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {\r
366                         Ext.getDom(o.el).innerHTML = response.responseText;\r
367                     });\r
368                 }\r
369                 \r
370                 var p = o.params,\r
371                     url = o.url || me.url,                \r
372                     method,\r
373                     cb = {success: handleResponse,\r
374                           failure: handleFailure,\r
375                           scope: me,\r
376                           argument: {options: o},\r
377                           timeout : o.timeout || me.timeout\r
378                     },\r
379                     form,                    \r
380                     serForm;                    \r
381                   \r
382                      \r
383                 if (Ext.isFunction(p)) {\r
384                     p = p.call(o.scope||WINDOW, o);\r
385                 }\r
386                                                            \r
387                 p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p);    \r
388                 \r
389                 if (Ext.isFunction(url)) {\r
390                     url = url.call(o.scope || WINDOW, o);\r
391                 }\r
392     \r
393                 if((form = Ext.getDom(o.form))){\r
394                     url = url || form.action;\r
395                      if(o.isUpload || /multipart\/form-data/i.test(form.getAttribute("enctype"))) { \r
396                          return doFormUpload.call(me, o, p, url);\r
397                      }\r
398                     serForm = Ext.lib.Ajax.serializeForm(form);                    \r
399                     p = p ? (p + '&' + serForm) : serForm;\r
400                 }\r
401                 \r
402                 method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);\r
403                 \r
404                 if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){\r
405                     var dcp = o.disableCachingParam || me.disableCachingParam;\r
406                     url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));\r
407                 }\r
408                 \r
409                 o.headers = Ext.apply(o.headers || {}, me.defaultHeaders || {});\r
410                 \r
411                 if(o.autoAbort === true || me.autoAbort) {\r
412                     me.abort();\r
413                 }\r
414                  \r
415                 if((method == GET || o.xmlData || o.jsonData) && p){\r
416                     url = Ext.urlAppend(url, p);  \r
417                     p = '';\r
418                 }\r
419                 return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));\r
420             }else{                \r
421                 return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;\r
422             }\r
423         },\r
424     \r
425         <div id="method-Ext.data.Connection-isLoading"></div>/**\r
426          * Determine whether this object has a request outstanding.\r
427          * @param {Number} transactionId (Optional) defaults to the last transaction\r
428          * @return {Boolean} True if there is an outstanding request.\r
429          */\r
430         isLoading : function(transId){\r
431             return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId;            \r
432         },\r
433     \r
434         <div id="method-Ext.data.Connection-abort"></div>/**\r
435          * Aborts any outstanding request.\r
436          * @param {Number} transactionId (Optional) defaults to the last transaction\r
437          */\r
438         abort : function(transId){\r
439             if(transId || this.isLoading()){\r
440                 Ext.lib.Ajax.abort(transId || this.transId);\r
441             }\r
442         }\r
443     });\r
444 })();\r
445 \r
446 <div id="cls-Ext.Ajax"></div>/**\r
447  * @class Ext.Ajax\r
448  * @extends Ext.data.Connection\r
449  * <p>The global Ajax request class that provides a simple way to make Ajax requests\r
450  * with maximum flexibility.</p>\r
451  * <p>Since Ext.Ajax is a singleton, you can set common properties/events for it once\r
452  * and override them at the request function level only if necessary.</p>\r
453  * <p>Common <b>Properties</b> you may want to set are:<div class="mdetail-params"><ul>\r
454  * <li><b><tt>{@link #method}</tt></b><p class="sub-desc"></p></li>\r
455  * <li><b><tt>{@link #extraParams}</tt></b><p class="sub-desc"></p></li>\r
456  * <li><b><tt>{@link #url}</tt></b><p class="sub-desc"></p></li>\r
457  * </ul></div>\r
458  * <pre><code>\r
459 // Default headers to pass in every request\r
460 Ext.Ajax.defaultHeaders = {\r
461     'Powered-By': 'Ext'\r
462 };\r
463  * </code></pre> \r
464  * </p>\r
465  * <p>Common <b>Events</b> you may want to set are:<div class="mdetail-params"><ul>\r
466  * <li><b><tt>{@link Ext.data.Connection#beforerequest beforerequest}</tt></b><p class="sub-desc"></p></li>\r
467  * <li><b><tt>{@link Ext.data.Connection#requestcomplete requestcomplete}</tt></b><p class="sub-desc"></p></li>\r
468  * <li><b><tt>{@link Ext.data.Connection#requestexception requestexception}</tt></b><p class="sub-desc"></p></li>\r
469  * </ul></div>\r
470  * <pre><code>\r
471 // Example: show a spinner during all Ajax requests\r
472 Ext.Ajax.on('beforerequest', this.showSpinner, this);\r
473 Ext.Ajax.on('requestcomplete', this.hideSpinner, this);\r
474 Ext.Ajax.on('requestexception', this.hideSpinner, this);\r
475  * </code></pre> \r
476  * </p>\r
477  * <p>An example request:</p>\r
478  * <pre><code>\r
479 // Basic request\r
480 Ext.Ajax.{@link Ext.data.Connection#request request}({\r
481    url: 'foo.php',\r
482    success: someFn,\r
483    failure: otherFn,\r
484    headers: {\r
485        'my-header': 'foo'\r
486    },\r
487    params: { foo: 'bar' }\r
488 });\r
489 \r
490 // Simple ajax form submission\r
491 Ext.Ajax.{@link Ext.data.Connection#request request}({\r
492     form: 'some-form',\r
493     params: 'foo=bar'\r
494 });\r
495  * </code></pre> \r
496  * </p>\r
497  * @singleton\r
498  */\r
499 Ext.Ajax = new Ext.data.Connection({\r
500     <div id="cfg-Ext.Ajax-url"></div>/**\r
501      * @cfg {String} url @hide\r
502      */\r
503     <div id="cfg-Ext.Ajax-extraParams"></div>/**\r
504      * @cfg {Object} extraParams @hide\r
505      */\r
506     <div id="cfg-Ext.Ajax-defaultHeaders"></div>/**\r
507      * @cfg {Object} defaultHeaders @hide\r
508      */\r
509     <div id="cfg-Ext.Ajax-method"></div>/**\r
510      * @cfg {String} method (Optional) @hide\r
511      */\r
512     <div id="cfg-Ext.Ajax-timeout"></div>/**\r
513      * @cfg {Number} timeout (Optional) @hide\r
514      */\r
515     <div id="cfg-Ext.Ajax-autoAbort"></div>/**\r
516      * @cfg {Boolean} autoAbort (Optional) @hide\r
517      */\r
518 \r
519     <div id="cfg-Ext.Ajax-disableCaching"></div>/**\r
520      * @cfg {Boolean} disableCaching (Optional) @hide\r
521      */\r
522 \r
523     <div id="prop-Ext.Ajax-disableCaching"></div>/**\r
524      * @property  disableCaching\r
525      * True to add a unique cache-buster param to GET requests. (defaults to true)\r
526      * @type Boolean\r
527      */\r
528     <div id="prop-Ext.Ajax-url"></div>/**\r
529      * @property  url\r
530      * The default URL to be used for requests to the server. (defaults to undefined)\r
531      * If the server receives all requests through one URL, setting this once is easier than\r
532      * entering it on every request.\r
533      * @type String\r
534      */\r
535     <div id="prop-Ext.Ajax-extraParams"></div>/**\r
536      * @property  extraParams\r
537      * An object containing properties which are used as extra parameters to each request made\r
538      * by this object (defaults to undefined). Session information and other data that you need\r
539      * to pass with each request are commonly put here.\r
540      * @type Object\r
541      */\r
542     <div id="prop-Ext.Ajax-defaultHeaders"></div>/**\r
543      * @property  defaultHeaders\r
544      * An object containing request headers which are added to each request made by this object\r
545      * (defaults to undefined).\r
546      * @type Object\r
547      */\r
548     <div id="prop-Ext.Ajax-method"></div>/**\r
549      * @property  method\r
550      * The default HTTP method to be used for requests. Note that this is case-sensitive and\r
551      * should be all caps (defaults to undefined; if not set but params are present will use\r
552      * <tt>"POST"</tt>, otherwise will use <tt>"GET"</tt>.)\r
553      * @type String\r
554      */\r
555     <div id="prop-Ext.Ajax-timeout"></div>/**\r
556      * @property  timeout\r
557      * The timeout in milliseconds to be used for requests. (defaults to 30000)\r
558      * @type Number\r
559      */\r
560 \r
561     <div id="prop-Ext.Ajax-autoAbort"></div>/**\r
562      * @property  autoAbort\r
563      * Whether a new request should abort any pending requests. (defaults to false)\r
564      * @type Boolean\r
565      */\r
566     autoAbort : false,\r
567 \r
568     <div id="method-Ext.Ajax-serializeForm"></div>/**\r
569      * Serialize the passed form into a url encoded string\r
570      * @param {String/HTMLElement} form\r
571      * @return {String}\r
572      */\r
573     serializeForm : function(form){\r
574         return Ext.lib.Ajax.serializeForm(form);\r
575     }\r
576 });\r
577 </pre>    \r
578 </body>\r
579 </html>