X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/src/data/Connection.js diff --git a/src/data/Connection.js b/src/data/Connection.js index 80513e48..1e272405 100644 --- a/src/data/Connection.js +++ b/src/data/Connection.js @@ -1,5 +1,18 @@ +/* + +This file is part of Ext JS 4 + +Copyright (c) 2011 Sencha Inc + +Contact: http://www.sencha.com/contact + +GNU General Public License Usage +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. + +If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. + +*/ /** - * @class Ext.data.Connection * The Connection class encapsulates a connection to the page's originating domain, allowing requests to be made either * to a configured URL, or to a URL specified at request time. * @@ -7,7 +20,7 @@ * to the statement immediately following the {@link #request} call. To process returned data, use a success callback * in the request options object, or an {@link #requestcomplete event listener}. * - *

File Uploads

+ * # File Uploads * * File uploads are not performed using normal "Ajax" techniques, that is they are not performed using XMLHttpRequests. * Instead the form is submitted in the standard manner with the DOM <form> element temporarily modified to have its @@ -18,8 +31,8 @@ * send the return object, then the Content-Type header must be set to "text/html" in order to tell the browser to * insert the text unchanged into the document body. * - * Characters which are significant to an HTML parser must be sent as HTML entities, so encode "<" as "&lt;", "&" as - * "&amp;" etc. + * Characters which are significant to an HTML parser must be sent as HTML entities, so encode `<` as `<`, `&` as + * `&` etc. * * The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a * responseText property in order to conform to the requirements of event handlers and callbacks. @@ -46,25 +59,39 @@ Ext.define('Ext.data.Connection', { password: '', /** - * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true) - * @type Boolean + * @cfg {Boolean} disableCaching + * True to add a unique cache-buster param to GET requests. */ disableCaching: true, /** - * @cfg {String} disableCachingParam (Optional) Change the parameter which is sent went disabling caching - * through a cache buster. Defaults to '_dc' - * @type String + * @cfg {Boolean} withCredentials + * True to set `withCredentials = true` on the XHR object + */ + withCredentials: false, + + /** + * @cfg {Boolean} cors + * True to enable CORS support on the XHR object. Currently the only effect of this option + * is to use the XDomainRequest object instead of XMLHttpRequest if the browser is IE8 or above. + */ + cors: false, + + /** + * @cfg {String} disableCachingParam + * Change the parameter which is sent went disabling caching through a cache buster. */ disableCachingParam: '_dc', /** - * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000) + * @cfg {Number} timeout + * The timeout in milliseconds to be used for requests. */ timeout : 30000, /** - * @param {Object} extraParams (Optional) Any parameters to be appended to the request. + * @cfg {Object} extraParams + * Any parameters to be appended to the request. */ useDefaultHeader : true, @@ -80,29 +107,27 @@ Ext.define('Ext.data.Connection', { /** * @event beforerequest * Fires before a network request is made to retrieve a data object. - * @param {Connection} conn This Connection object. + * @param {Ext.data.Connection} conn This Connection object. * @param {Object} options The options config object passed to the {@link #request} method. */ 'beforerequest', /** * @event requestcomplete * Fires if the request was successfully completed. - * @param {Connection} conn This Connection object. + * @param {Ext.data.Connection} conn This Connection object. * @param {Object} response The XHR object containing the response data. - * See The XMLHttpRequest Object - * for details. + * See [The XMLHttpRequest Object](http://www.w3.org/TR/XMLHttpRequest/) for details. * @param {Object} options The options config object passed to the {@link #request} method. */ 'requestcomplete', /** * @event requestexception * Fires if an error HTTP status was returned from the server. - * See HTTP Status Code Definitions + * See [HTTP Status Code Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) * for details of HTTP status codes. - * @param {Connection} conn This Connection object. + * @param {Ext.data.Connection} conn This Connection object. * @param {Object} response The XHR object containing the response data. - * See The XMLHttpRequest Object - * for details. + * See [The XMLHttpRequest Object](http://www.w3.org/TR/XMLHttpRequest/) for details. * @param {Object} options The options config object passed to the {@link #request} method. */ 'requestexception' @@ -112,101 +137,112 @@ Ext.define('Ext.data.Connection', { }, /** - *

Sends an HTTP request to a remote server.

- *

Important: Ajax server requests are asynchronous, and this call will + * Sends an HTTP request to a remote server. + * + * **Important:** Ajax server requests are asynchronous, and this call will * return before the response has been received. Process any returned data - * in a callback function.

- *

-Ext.Ajax.request({
-url: 'ajax_demo/sample.json',
-success: function(response, opts) {
-  var obj = Ext.decode(response.responseText);
-  console.dir(obj);
-},
-failure: function(response, opts) {
-  console.log('server-side failure with status code ' + response.status);
-}
-});
-     * 
- *

To execute a callback function in the correct scope, use the scope option.

- * @param {Object} options An object which may contain the following properties:

- *

The options object may also contain any other property which might be needed to perform - * postprocessing in a callback because it is passed to callback functions.

- * @return {Object} request The request object. This may be used - * to cancel the request. + * DOM `` element temporarily modified to have its [target][] set to refer to a dynamically + * generated, hidden `