Upgrade to ExtJS 4.0.7 - Released 10/19/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 {Boolean} disableCaching
84      * True to add a unique cache-buster param to GET requests. Defaults to true.
85      */
86     /**
87      * @property {String} url
88      * The default URL to be used for requests to the server.
89      * If the server receives all requests through one URL, setting this once is easier than
90      * entering it on every request.
91      */
92     /**
93      * @property {Object} extraParams
94      * An object containing properties which are used as extra parameters to each request made
95      * by this object. Session information and other data that you need
96      * to pass with each request are commonly put here.
97      */
98     /**
99      * @property {Object} defaultHeaders
100      * An object containing request headers which are added to each request made by this object.
101      */
102     /**
103      * @property {String} method
104      * The default HTTP method to be used for requests. Note that this is case-sensitive and
105      * should be all caps (if not set but params are present will use
106      * <tt>"POST"</tt>, otherwise will use <tt>"GET"</tt>.)
107      */
108     /**
109      * @property {Number} timeout
110      * The timeout in milliseconds to be used for requests. Defaults to 30000.
111      */
112
113     /**
114      * @property {Boolean} autoAbort
115      * Whether a new request should abort any pending requests.
116      */
117     autoAbort : false
118 });