PDA

View Full Version : IFrame fallback for Ajax-Requests



nanotron
27 Aug 2008, 6:31 AM
Hi all,

sometimes I need to make ajax-requests on IE6 with deactivated Active-X.
So I wrote this little overwrite which utilize the file-upload-functionality:


var xhr = Ext.lib.Ajax.getConnectionObject();
if(!xhr){
MyAjax = function(o) {
Ext.apply(this);
this.method = this.method || 'POST';
MyAjax.superclass.constructor.call(this);

if (this.success) {
this.on('requestcomplete', this.success);
}

if (this.failure) {
this.on('requestfailed', this.failure);
}
};
Ext.extend(MyAjax, Ext.data.Connection, {
request : function(o){
if(!o.params)
o.params = 'ajax=1';
else if(typeof o.params == 'object')
o.params.ajax = '1';
else
o.params += '&ajax=1';
if(!o.form)
o.form = "dummyForm";
if(!o.isUpload)
o.isUpload = true;
o.async = o.async || false;
MyAjax.superclass.request.call(this, o);
}
});
Ext.Ajax = new MyAjax();
}


A form with id="dummyForm" must be present in the html-file.

Unfortunately it doesnt work with hendricd's basex-extension.
Maybe it will help somebody.

Cheers

hendricd
27 Aug 2008, 7:08 AM
....Unfortunately it doesnt work with hendricd's basex-extension.@nanotron -- For basex, modify the getConnectionObject method to assert options:
(Fix in SVN/trunk coming shortly)


getConnectionObject:function(uri, options)
{
var o,f,e=Ext.emptyFn;
var tId = this.transactionId;
options || (options = {});
try
{
if(f = options.proxied){ /*scriptTag Support */
.....
and, something doesn't look quite right here:


var xhr = Ext.lib.Ajax.getConnectionObject();
if(!xhr){
MyAjax = function(o) {
Ext.apply(this, o || {});
this.method = this.method || 'POST';
MyAjax.superclass.constructor.call(this);

if (this.success) {
this.on('requestcomplete', this.success);
}

if (this.failure) {
this.on('requestfailed', this.failure);
}
};
Ext.extend(MyAjax, Ext.data.Connection, {
request : function(o){
if(!o.params)
o.params = 'ajax=1';
else if(typeof o.params == 'object')
o.params.ajax = '1';
else
o.params += '&ajax=1';
if(!o.form)
o.form = "dummyForm";
if(!o.isUpload)
o.isUpload = true;
o.async = o.async || false;
MyAjax.superclass.request.call(this, o);
}
});
Ext.Ajax = new MyAjax();
}

mrsunshine
6 Oct 2008, 1:59 AM
Hi,
i have exactly the same problem with IE6 and activeX. So thank you for you solution. can you say me how the dummy form must look like? Which config is needed?

thank you nils

nanotron
6 Oct 2008, 2:17 AM
You only need in your html-file

<form id="dummyForm" enctype="multipart/form-data" style="display:none;"></form>:

cheers
andreas

mrsunshine
6 Oct 2008, 2:25 AM
Thank you very much!!!

it works! =D>

mrsunshine
29 Oct 2008, 8:28 AM
Pleas notice that if you have arrays as parameter you have to override the Ext.data.Connection

for more information read my bug description an bugfix solution:
http://extjs.com/forum/showthread.php?p=244746#post244746

mrsunshine
5 Jun 2009, 1:29 AM
Is there already a solution for Ext JS 3.0 ?