Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: open

Message Too Old, No Replies

[ajax] send data with POST and getting back xml

     
8:57 pm on Apr 17, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 30, 2008
posts: 42
votes: 0


Hi everybody!

I have a page with a textarea and I want to send it to a PHP script as a POST variable so that I can store it into a database and then getting back an xml files which contains the result of the operation.

My ajax code looks like this:
xhr.open("POST", strName, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.overrideMimeType('text/xml');
xhr.send(parameters);


This works well in FF but in IE I get an error. Apparently the object is not correctly created. Where am I wrong?

Probably it's a common problem but I searched the forum and didn't find anything...
Thanks for your help!
9:30 pm on Apr 17, 2011 (gmt 0)

Preferred Member

5+ Year Member

joined:Aug 18, 2008
posts:408
votes: 0


IE does not support overrideMimeType so change
xhr.overrideMimeType('text/xml');

to:
if (xhr.overrideMimeType) {
xhr.overrideMimeType('text/xml');
}
9:37 pm on Apr 17, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 30, 2008
posts: 42
votes: 0


Thanks a lot!
Quoting a popular movie: "You are my personal Jesus Christ" :)