Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / Ajax.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @class Ext.Ajax
17  * @singleton
18  * @markdown
19  * @extends Ext.data.Connection
20
21 A singleton instance of an {@link Ext.data.Connection}. This class
22 is used to communicate with your server side code. It can be used as follows:
23
24     Ext.Ajax.request({
25         url: 'page.php',
26         params: {
27             id: 1
28         },
29         success: function(response){
30             var text = response.responseText;
31             // process server response here
32         }
33     });
34
35 Default options for all requests can be set by changing a property on the Ext.Ajax class:
36
37     Ext.Ajax.timeout = 60000; // 60 seconds
38
39 Any options specified in the request method for the Ajax request will override any
40 defaults set on the Ext.Ajax class. In the code sample below, the timeout for the
41 request will be 60 seconds.
42
43     Ext.Ajax.timeout = 120000; // 120 seconds
44     Ext.Ajax.request({
45         url: 'page.aspx',
46         timeout: 60000
47     });
48
49 In general, this class will be used for all Ajax requests in your application.
50 The main reason for creating a separate {@link Ext.data.Connection} is for a
51 series of requests that share common settings that are different to all other
52 requests in the application.
53
54  */
55 Ext.define('Ext.Ajax', {
56     extend: 'Ext.data.Connection',
57     singleton: true,
58
59     /**
60      * @cfg {String} url @hide
61      */
62     /**
63      * @cfg {Object} extraParams @hide
64      */
65     /**
66      * @cfg {Object} defaultHeaders @hide
67      */
68     /**
69      * @cfg {String} method (Optional) @hide
70      */
71     /**
72      * @cfg {Number} timeout (Optional) @hide
73      */
74     /**
75      * @cfg {Boolean} autoAbort (Optional) @hide
76      */
77
78     /**
79      * @cfg {Boolean} disableCaching (Optional) @hide
80      */
81
82     /**
83      * @property  disableCaching
84      * True to add a unique cache-buster param to GET requests. (defaults to true)
85      * @type Boolean
86      */
87     /**
88      * @property  url
89      * The default URL to be used for requests to the server. (defaults to undefined)
90      * If the server receives all requests through one URL, setting this once is easier than
91      * entering it on every request.
92      * @type String
93      */
94     /**
95      * @property  extraParams
96      * An object containing properties which are used as extra parameters to each request made
97      * by this object (defaults to undefined). Session information and other data that you need
98      * to pass with each request are commonly put here.
99      * @type Object
100      */
101     /**
102      * @property  defaultHeaders
103      * An object containing request headers which are added to each request made by this object
104      * (defaults to undefined).
105      * @type Object
106      */
107     /**
108      * @property  method
109      * The default HTTP method to be used for requests. Note that this is case-sensitive and
110      * should be all caps (defaults to undefined; if not set but params are present will use
111      * <tt>"POST"</tt>, otherwise will use <tt>"GET"</tt>.)
112      * @type String
113      */
114     /**
115      * @property  timeout
116      * The timeout in milliseconds to be used for requests. (defaults to 30000)
117      * @type Number
118      */
119
120     /**
121      * @property  autoAbort
122      * Whether a new request should abort any pending requests. (defaults to false)
123      * @type Boolean
124      */
125     autoAbort : false
126 });