PDA

View Full Version : ExtJs AJAX and defaultheaders.



muncher
8 Jul 2010, 3:18 PM
Below is my ajax call -


Ext.Ajax.request(//Ext.apply(this.createCallback(o),
{
url : 'getdata.php',
//method: 'GET',
defaultHeaders: {'Content-Type': 'text/xml;charset=UTF-8'},
params:xmlData, //add our values
success: function(result, request) {

},
failure: function ( result, request) {
al
}
});


Seems like the default headers aren't getting set. I can see in webscarab that default heder is nt the form i had entered. don't know what to do. My Spring service is set to accept any type of header, but seems like the xml data posted along with this request gets encoded and the server cannot figure out how to decode and map to the object.

13 Jul 2010, 5:09 AM
try just setting headers.

Animal
13 Jul 2010, 5:17 AM
Works for me. From Firebug when I execute that code snippet (with xmlData set to {}):




Host localhost:8080
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-gb,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Type text/xml;charset=UTF-8
X-Requested-With XMLHttpRequest

Animal
13 Jul 2010, 5:22 AM
But sending params will not send XML. So your header will be untruthful.