I can't get dojo's ajax features working properly using dojo.xhrGet, dojo.xhrPost, and dojo.rawXhrPost. They seem to be working fine in Firefox 2 but the response object is different in IE 7. Here is an example:
My Ajax call:
dojo.xhrGet({url: "testXML.jsp",
handleAs: "xml",
load: getLoad,
error: function(response, ioArgs){
console.error("HTTP status code: ",ioArgs.xhr.status);
return response;
}
});
}
the returned xml
<person name='Fred'><age>24</age><weight>180</weight></person>
The response handler function
function getLoad(response, ioArgs){
var table = document.createElement("table");
var tbody = document.createElement("tbody");
var tr,td,text;
table.appendChild(tbody);
tr = document.createElement("tr");
//get xml tags
********//IE 7 does not get past the next line *********
var person = response.getElementsByTagName("person")[0].getAttribute("name");
var age = response.getElementsByTagName("age")[0].firstChild.nodeValue;
var weight = response.getElementsByTagName("weight")[0].firstChild.nodeValue;
td = document.createElement("td");
td.appendChild(document.createTextNode(person));
tr.appendChild(td);
td = document.createElement("td");
td.appendChild(document.createTextNode(age));
tr.appendChild(td);
td = document.createElement("td");
td.appendChild(document.createTextNode(weight));
tr.appendChild(td);
tbody.appendChild(tr);
dojo.byId("xhrGet").appendChild(table);
}

Have you used the console?
Have you used the Firebug lite console to see what type of object your response is?
-Karl
Also check the Content-Type
Also check the Content-Type that the server returns. IIRC, IE is fairly picky, I think text/xml is a safe bet.
Strange I thought it was
Strange I thought it was better to use "application/xhtml+xml". I've been using it until now with my own ajax functions and it hasn't given me any problems. "text/xml" works in IE and FF with dojo though so "text/xml" it is. Thanks for the help!
I'm encountering this same
I'm encountering this same problem using Dojo 1.2 on IE 7.0.5730.11. Fx 3.0.1 is OK. The IE browser says the response is [Object] but Fx correctly says the response is [Object XMLDocument]. Even setting the content-type header to 'text/xml' doesn't change the result.
Is there a solid fix or workaround for this in Dojo 1.2? Thanks!
<script type="text/javascript" src="../dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
</script>
<script type="text/javascript">
dojo.rawXhrPost({
url: '/digivice/tests/data.php',
sync: true,
handleAs: 'xml',
postData: 'a=b',
handle: function(response, ioArgs) {
var text = '';
alert(response);
}});
</script>
</head>
<body>
</body>
<!-- data.php
<?php
header("Content-Type: text/xml");
?>
<?xml version="1.0" encoding="UTF-8"?>
<MYXML attr="1">
</MYXML>
-->
Please ignore my last post.
Please ignore my last post. It seems that this is working properly but the alert tag doesn't report the same info in IE. I was also using some Fx-only DOM API later on that prevented IE from parsing the response (in my real app). I have a lot to learn about cross-browser DOM manipulation. :)