View Full Version : Http-Headers for cross-domain Ajax request (FF3.5)

22 Jun 2009, 6:33 AM

I'm trying to make a cross domain XmlHttpRequest in FF3.5, Safari4.
Mozilla docs (https://developer.mozilla.org/En/HTTP_access_control) says that:
1. The request Content-Type should be application/x-www-form-urlencoded, multipart/form-data, or text/plain.
2. The request shouldn't set custom Headers like X-Requested-With.

I'm trying to send an xmlData so the Content-Type is text/xml

How can I remove the X-Requested-With header that Ext is setting?
Can I change the Content-Type to text/plain or do I need to send the XML as a param so the Content-Type will be application/x-www-form-urlencoded?


22 Jun 2009, 6:50 AM
1. Use:

Ext.lib.Ajax.useDefaultXhrHeader = false;

2. Specify the headers in the request (or the defaultHeaders in the connection object):

headers: {'Content-Type': 'text/plain'}

22 Jun 2009, 7:50 AM
This works:

Ext.lib.Ajax.useDefaultXhrHeader = false;

I've tried setting the Content-Type with:

headers: {'Content-Type': 'text/plain'}
But I think that line 1346 of ext-core-debug.js override it:

if(xmlData || jsonData){
initHeader('Content-Type', xmlData ? 'text/xml' : 'application/json');
data = xmlData || Ext.encode(jsonData);

22 Jun 2009, 10:43 AM
Fixed in SVN