Dumb Ajax question

Why does IE hate me?

Page 1 of 1

2 Replies - 666 Views - Last Post: 11 March 2009 - 11:38 PM

#1 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Dumb Ajax question

Posted 11 March 2009 - 06:54 PM

Why does this
Ajax.request.responseXML.getElementsByTagName("result")[0].firstChild.nodeValue work in FireFox but not in IE?

I use the following code to get the request object:

unction GetXmlHttpObject() {
	var xmlHttp;
	try {  
		if (window.XMLHttpRequest) {
			xmlHttp=new XMLHttpRequest();
			alert("XMLHttpRequest");
		} else if (window.ActiveXObject) {
			try { 
				// Internet Explorer
		   		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				alert("Msxml2.XMLHTTP");
			} catch (e) {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				alert("Microsoft.XMLHTTP");
			}   
		} else {
			alert("No XMLHttp Object could be found");
		}			
	} catch (e) {
		alert("Could not create Ajax call: " + e);		
	}
	return xmlHttp;
}


The example code I used works in both IE and FF... but my own attempt has been full of fail.

now if I check Ajax.request.responseXML then I get the XML in text form:
<?xml version="1.0" ?><result><![CDATA[Something something something]]></result>


Perhaps the CDATA tag is messing me up...

Is This A Good Question/Topic? 0
  • +

Replies To: Dumb Ajax question

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Dumb Ajax question

Posted 11 March 2009 - 10:38 PM

Well the responseXML does not contain a document. So I googled for solutions and aparently responceXML does not work in IE unless the Content-Type is set to "text/xml" -- no big deal to set that...

well it STILL does not work. The responceText works great. I am just plain done with IE. If I had a choice I would round up all of the IE users in the world. Give them 1 chance to switch to another browser: if they don't, shoot them in the head.

THEN find the developers of IE and draw and quarter them slowly -- something like the rope moves once nanometer every time IE screws something up... well perhaps that would be too fast.

I just wanted to do something simple... it was supposed to take me a couple of hours... I am working on 3 days all because IE is a bitch.
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Dumb Ajax question

Posted 11 March 2009 - 11:38 PM

ok.... got it... little embarrassing...

Turns out that changing the mime type did in fact work. The problem was that IE had cached the old response and so it was not getting the new updated response with the Content-type set to "text/xml".

I discovered this by looking at the results of: alert("Content-Type: " +Ajax.request.getResponseHeader("Content-type"));

The other work around is to go ahead and an create an Microsoft.XMLDOM activex object and parse the responceText.

IE users have a short reprieve before I go postal.

This post has been edited by NickDMax: 11 March 2009 - 11:39 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1