Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / Ajax.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-Ajax'>/**
19 </span> * @class Ext.Ajax
20  * @singleton
21  * @markdown
22  * @extends Ext.data.Connection
23
24 A singleton instance of an {@link Ext.data.Connection}. This class
25 is used to communicate with your server side code. It can be used as follows:
26
27     Ext.Ajax.request({
28         url: 'page.php',
29         params: {
30             id: 1
31         },
32         success: function(response){
33             var text = response.responseText;
34             // process server response here
35         }
36     });
37
38 Default options for all requests can be set by changing a property on the Ext.Ajax class:
39
40     Ext.Ajax.timeout = 60000; // 60 seconds
41
42 Any options specified in the request method for the Ajax request will override any
43 defaults set on the Ext.Ajax class. In the code sample below, the timeout for the
44 request will be 60 seconds.
45
46     Ext.Ajax.timeout = 120000; // 120 seconds
47     Ext.Ajax.request({
48         url: 'page.aspx',
49         timeout: 60000
50     });
51
52 In general, this class will be used for all Ajax requests in your application.
53 The main reason for creating a separate {@link Ext.data.Connection} is for a
54 series of requests that share common settings that are different to all other
55 requests in the application.
56
57  */
58 Ext.define('Ext.Ajax', {
59     extend: 'Ext.data.Connection',
60     singleton: true,
61
62 <span id='Ext-Ajax-cfg-url'>    /**
63 </span>     * @cfg {String} url @hide
64      */
65 <span id='Ext-Ajax-cfg-extraParams'>    /**
66 </span>     * @cfg {Object} extraParams @hide
67      */
68 <span id='Ext-Ajax-cfg-defaultHeaders'>    /**
69 </span>     * @cfg {Object} defaultHeaders @hide
70      */
71 <span id='Ext-Ajax-cfg-method'>    /**
72 </span>     * @cfg {String} method (Optional) @hide
73      */
74 <span id='Ext-Ajax-cfg-timeout'>    /**
75 </span>     * @cfg {Number} timeout (Optional) @hide
76      */
77 <span id='Ext-Ajax-cfg-autoAbort'>    /**
78 </span>     * @cfg {Boolean} autoAbort (Optional) @hide
79      */
80
81 <span id='Ext-Ajax-cfg-disableCaching'>    /**
82 </span>     * @cfg {Boolean} disableCaching (Optional) @hide
83      */
84
85 <span id='Ext-Ajax-property-disableCaching'>    /**
86 </span>     * @property  disableCaching
87      * True to add a unique cache-buster param to GET requests. (defaults to true)
88      * @type Boolean
89      */
90 <span id='Ext-Ajax-property-url'>    /**
91 </span>     * @property  url
92      * The default URL to be used for requests to the server. (defaults to undefined)
93      * If the server receives all requests through one URL, setting this once is easier than
94      * entering it on every request.
95      * @type String
96      */
97 <span id='Ext-Ajax-property-extraParams'>    /**
98 </span>     * @property  extraParams
99      * An object containing properties which are used as extra parameters to each request made
100      * by this object (defaults to undefined). Session information and other data that you need
101      * to pass with each request are commonly put here.
102      * @type Object
103      */
104 <span id='Ext-Ajax-property-defaultHeaders'>    /**
105 </span>     * @property  defaultHeaders
106      * An object containing request headers which are added to each request made by this object
107      * (defaults to undefined).
108      * @type Object
109      */
110 <span id='Ext-Ajax-property-method'>    /**
111 </span>     * @property  method
112      * The default HTTP method to be used for requests. Note that this is case-sensitive and
113      * should be all caps (defaults to undefined; if not set but params are present will use
114      * &lt;tt&gt;&quot;POST&quot;&lt;/tt&gt;, otherwise will use &lt;tt&gt;&quot;GET&quot;&lt;/tt&gt;.)
115      * @type String
116      */
117 <span id='Ext-Ajax-property-timeout'>    /**
118 </span>     * @property  timeout
119      * The timeout in milliseconds to be used for requests. (defaults to 30000)
120      * @type Number
121      */
122
123 <span id='Ext-Ajax-property-autoAbort'>    /**
124 </span>     * @property  autoAbort
125      * Whether a new request should abort any pending requests. (defaults to false)
126      * @type Boolean
127      */
128     autoAbort : false
129 });</pre>
130 </body>
131 </html>