PDA

View Full Version : support for cross-domain ajax requests



dolittle
16 Jun 2009, 2:46 PM
I'm trying to find a way to add cross domain ajax requests. I think that for FF3.5/Safari4 no change is required in ext link (http://ejohn.org/blog/cross-site-xmlhttprequest/)
For older browsers I'll use scriptTagProxy

For security reasons IE8 uses a new object, named XDomainRequest (http://msdn.microsoft.com/en-us/library/cc288060(VS.85).aspx).
Any idea how to override ext-core so it'll be possible to pass a "x-domain: true" config option? Can I just replace XMLHttpRequest with XDomainRequest for IE8?
This is where ext creates the xmlHttpRequest Object:

// private
function createXhrObject(transactionId) {
var http;

try {
http = new XMLHttpRequest();
} catch(e) {
for (var i = 0; i < activeX.length; ++i) {
try {
http = new ActiveXObject(activeX[i]);
break;
} catch(e) {}
}
} finally {
return {conn : http, tId : transactionId};
}
}

Another related post (http://www.extjs.com/forum/showthread.php?t=58306&highlight=XDomainRequest)

hendricd
16 Jun 2009, 6:48 PM
@dolittle -- The latest ext-basex adapter now implements the cross-domain request for => IE8. You can see it (and multipart response handling) in action here (http://demos.theactivegroup.com/demodesk.html?demo=basex&script=multipart).

dolittle
17 Jun 2009, 8:52 AM
@dolittle -- The latest ext-basex adapter now implements the cross-domain request for => IE8. You can see it (and multipart response handling) in action here.

What applications can benefit from 'multipart response'?
Is it new?

hendricd
17 Jun 2009, 9:00 AM
The ability to return/handle multiple content-types (in parts) from a single request is quite powerful, especially when applied to the concepts introduced by Ext.Direct. :-?

Most browsers (but not yet IE) will support incremental response handling as each part is 'flushed' from the server.

Also note: IE's XDomainRequest is very limiting:
- no header support,
- no readyState, status, statusText, properties, and
- no support for multi-part responses.

dolittle
17 Jun 2009, 11:02 AM
Also note: IE's XDomainRequest is very limiting:
- no header support,
- no readyState, status, statusText, properties, and
- no support for multi-part responses.

Does that means I can't use Ext's success and failure handlers?
from XDomainRequest (http://msdn.microsoft.com/en-us/library/cc288060%28VS.85%29.aspx) docs it seems that it supports onprogress, onerror and onload. Will it require further modifications to Ext?

hendricd
17 Jun 2009, 11:18 AM
Does that means I can't use Ext's success and failure handlers?
from XDomainRequest (http://msdn.microsoft.com/en-us/library/cc288060%28VS.85%29.aspx) docs it seems that it supports onprogress, onerror and onload. Will it require further modifications to Ext?

Ext's current ext-base adapter uses a timer polling mechanism for raising callbacks when the readyState finally hits '4'. It would require a fair amount of revision to support the current and an event-based model.

Ext-basex already provides all that and maintains callback compatibility with the rest of the framework (whether asynchronous or not).