PDA

View Full Version : Ext.Ajax - POST custom text in HTTP body



kkris1983
23 Apr 2012, 5:06 AM
Hi,

I need to send text content of local file in HTTP body using Ext.Ajax.request.


Ext.Ajax.request({
url: 'test.jsp',
params: 'data to send',
method: 'POST',
headers: {
'Content-Type': 'my custom content type'
}
});


The problem is my custom Content-Type header is not set in the request properly.
What causes that behavior ? How to deal with that ?

Best regards kkris1983

friend
23 Apr 2012, 9:10 AM
Ajax (think "XMLHttpRequest") doesn't allow you to encode and send local file content. This can only be performed by an HTML Form post, which allows you to set the content type to multipart/form-data.

kkris1983
23 Apr 2012, 10:09 AM
Problem lies in our application. We accidentally overwrote all the headers on Ext.Ajax.on('beforerequest') that is why headers I applied wasn't sent at all. ;) I am able to send enything in HTTP body with correct Content-Type header

Thanks