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