X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/src/data/core/Connection.js?ds=sidebyside diff --git a/src/data/core/Connection.js b/src/data/core/Connection.js index f11a3bf8..99159ec0 100644 --- a/src/data/core/Connection.js +++ b/src/data/core/Connection.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.0.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.1.1 + * Copyright(c) 2006-2010 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ @@ -13,7 +13,7 @@ POST = 'POST', GET = 'GET', WINDOW = window; - + /** * @class Ext.data.Connection * @extends Ext.util.Observable @@ -46,7 +46,7 @@ * @constructor * @param {Object} config a configuration object. */ - Ext.data.Connection = function(config){ + Ext.data.Connection = function(config){ Ext.apply(this, config); this.addEvents( /** @@ -82,136 +82,6 @@ Ext.data.Connection.superclass.constructor.call(this); }; - // private - function handleResponse(response){ - this.transId = false; - var options = response.argument.options; - response.argument = options ? options.argument : null; - this.fireEvent(REQUESTCOMPLETE, this, response, options); - if(options.success){ - options.success.call(options.scope, response, options); - } - if(options.callback){ - options.callback.call(options.scope, options, true, response); - } - } - - // private - function handleFailure(response, e){ - this.transId = false; - var options = response.argument.options; - response.argument = options ? options.argument : null; - this.fireEvent(REQUESTEXCEPTION, this, response, options, e); - if(options.failure){ - options.failure.call(options.scope, response, options); - } - if(options.callback){ - options.callback.call(options.scope, options, false, response); - } - } - - // private - function doFormUpload(o, ps, url){ - var id = Ext.id(), - doc = document, - frame = doc.createElement('iframe'), - form = Ext.getDom(o.form), - hiddens = [], - hd, - encoding = 'multipart/form-data', - buf = { - target: form.target, - method: form.method, - encoding: form.encoding, - enctype: form.enctype, - action: form.action - }; - - Ext.apply(frame, { - id: id, - name: id, - className: 'x-hidden', - src: Ext.SSL_SECURE_URL // for IE - }); - doc.body.appendChild(frame); - - // This is required so that IE doesn't pop the response up in a new window. - if(Ext.isIE){ - document.frames[id].name = id; - } - - Ext.apply(form, { - target: id, - method: POST, - enctype: encoding, - encoding: encoding, - action: url || buf.action - }); - - // add dynamic params - ps = Ext.urlDecode(ps, false); - for(var k in ps){ - if(ps.hasOwnProperty(k)){ - hd = doc.createElement('input'); - hd.type = 'hidden'; - hd.value = ps[hd.name = k]; - form.appendChild(hd); - hiddens.push(hd); - } - } - - function cb(){ - var me = this, - // bogus response object - r = {responseText : '', - responseXML : null, - argument : o.argument}, - doc, - firstChild; - - try{ - doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document; - if(doc){ - if(doc.body){ - if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea - r.responseText = firstChild.value; - }else{ - r.responseText = doc.body.innerHTML; - } - } - //in IE the document may still have a body even if returns XML. - r.responseXML = doc.XMLDocument || doc; - } - } - catch(e) {} - - Ext.EventManager.removeListener(frame, LOAD, cb, me); - - me.fireEvent(REQUESTCOMPLETE, me, r, o); - - function runCallback(fn, scope, args){ - if(Ext.isFunction(fn)){ - fn.apply(scope, args); - } - } - - runCallback(o.success, o.scope, [r, o]); - runCallback(o.callback, o.scope, [o, true, r]); - - if(!me.debugUploads){ - setTimeout(function(){Ext.removeNode(frame);}, 100); - } - } - - Ext.EventManager.on(frame, LOAD, cb, this); - form.submit(); - - Ext.apply(form, buf); - Ext.each(hiddens, function(h) { - Ext.removeNode(h); - }); - } - Ext.extend(Ext.data.Connection, Ext.util.Observable, { /** * @cfg {String} url (Optional)
The default URL to be used for requests to the server. Defaults to undefined.
@@ -240,20 +110,20 @@ * @type Boolean */ autoAbort:false, - + /** * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true) * @type Boolean */ disableCaching: true, - + /** * @cfg {String} disableCachingParam (Optional) Change the parameter which is sent went disabling caching * through a cache buster. Defaults to '_dc' * @type String */ disableCachingParam: '_dc', - + /** *Sends an HTTP request to a remote server.
*Important: Ajax server requests are asynchronous, and this call will @@ -291,8 +161,8 @@ Ext.Ajax.request({ * parameters:
True if the form object is a file upload (will be set automatically if the form was * configured with enctype "multipart/form-data").
@@ -359,77 +229,77 @@ Ext.Ajax.request({ me.indicatorText = 'Common Events you may want to set are:
An example request:
*
@@ -491,7 +498,7 @@ Ext.Ajax.{@link Ext.data.Connection#request request}({
form: 'some-form',
params: 'foo=bar'
});
- *
+ *
*
* @singleton
*/