I really don't understand why I get a different response from xhrPost with Dojo. For IE8 it works fine and the XML can be read - but in Firefox it works differently and there is no such attribute as "serverResponse.results[0].xml" - see below:
var serverResponse = dojo.xhrPost(xhrArgs);
serverResponse.results[0].xml
like you get in IE8.
Does anyone know how to handle responses properly in Firefox when using xhrPost. Cheers.
var message = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">' +
'<soap12:Body>' +
'<MineSearch xmlns="http://localhost/">' +
'<x>' + inPoint.x + '</x>' +
'<y>' + inPoint.y + '</y>' +
'<buffer>' + buffer + '</buffer>' +
'</MineSearch>' +
'</soap12:Body>' +
'</soap12:Envelope>';
//The parameters to pass to xhrPost, the message, and the url to send it to
//Also, how to handle the return and callbacks.
var xhrArgs = { url: "http://localhost/ApplicationServices.asmx?op=MineSearch",
postData: message,
headers: { "Content-Type": "application/soap+xml" },
handleAs: "xml",
sync: true,
load: function(data) {
dojo.byId("footer").innerHTML = "Message posted.";
},
error: function(error) {
dojo.byId("footer").innerHTML = "Message error.";
}
}
//Call the asynchronous xhrPost
var serverResponse = dojo.xhrPost(xhrArgs);
var xmldata = serverResponse.results[0].xml;
var xmlDoc;
if (window.DOMParser) {
parser = new DOMParser();
//Below is wrong somehow and the serverResponse.results[0] is probably wrong too.
xmlDoc = parser.parseFromString(serverResponse.results[0], "text/xml");
}
else // Internet Explorer
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xmldata);
}