XhrPost works differently with Firefox and IE8 - but how do I handle the response?

I really don't understand why I get a different response from xhrPost using Dojo. It works fine for IE8, and XML can be read, but it works differently in Firefox, and there is no such attribute as "serverResponse.results [0] .xml" - see below:

var serverResponse = dojo.xhrPost(xhrArgs);
serverResponse.results[0].xml

how do you get into IE8.

Does anyone know how to properly handle responses in Firefox when using xhrPost. Greetings.

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);
        }
+3
source share
1 answer

The returned object dojo.xhrPostis an object dojo.Deferred, and the response should not be retrieved from the object dojo.Deferred.

handleAs xml, XML load data.

var xhrArgs = { url: "http://localhost/ApplicationServices.asmx?op=MineSearch",
        postData: message,
        headers: { "Content-Type": "application/soap+xml" },
        handleAs: "xml",
        sync: true,
        load: function(data) {
            //data is the XML document
        },
        error: function(error) {
            dojo.byId("footer").innerHTML = "Message error.";

        }
}
dojo.xhrPost(xhrArgs);
+1

Source: https://habr.com/ru/post/1762883/


All Articles