Can't handle some characters from xml response with jquery

I am trying to get an XML response from the server side (java). I checked Fiddler , it returns a response as expected with code 200, but my JQuery mail function is sending an error response to me with a warning "Error retrieving xml from server". Is this an i18n question? I can read and parse other xml responses, how can I do the same with this kind of response

My code:

var jqxhr =$.post(redirectMainUrl+"globalaction.action", {
    sessiontoken: sessiontoken,
    action: "getFile",
    absFileName: file_path
},
function(xml1) {
    alert($(xml1).find("lastDayErrorLogs")
                 .children("log")
                 .children("logEvent")
                  .attr("message"));
})
.error(function() {
    if(jqxhr.responseText == 'INVALID_SESSION') {
        alert("Your Session has been timed out");
        window.location.replace(communities); 
    } else {
        alert("Error while getting xml from server");
        goToHomePage();
}
});

      

Server response (xml)

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="client.xsl"?>
<client version="1.0" >
      <product>
    <lastDayErrorLogs><log>

    <logEvent timestamp="2013-1-15_10:56:6"  severity="1" messageCode="CNX_53021" message="Solicitação inválida recebida." user="" stacktrace="" service="Rep_Service_Prd" serviceType="RS" clientNode="node01_jbpaetlsr2" pid="11900" threadName="11772" context="">
    </logEvent>
    </log></lastDayErrorLogs></product>
</client>

      

Content issue below attribute

message="Solicitação inválida recebida."

      

Update

Following @Unsung's comment I checked jqxhr.responseText

, it contains the xml response, so I decided to parse the internal xml error function.

but even after making changes to my function error

I am getting the following error in Internet Explorer 8

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
Timestamp: Tue, 22 Jan 2013 06:57:44 UTC


Message: Invalid XML: <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="client.xsl"?>
 <client version="1.0">
  <product>
<lastDayErrorLogs><log>

<logEvent timestamp="2013-1-15_10:56:6"  severity="1" messageCode="CNX_53021" message="Solicita invda recebida." user="" stacktrace="" service="Rep_Service_Prd" serviceType="RS" clientNode="node01_jbpaetlsr002" pid="11900" threadName="11772" context="">
</logEvent>
</log></lastDayErrorLogs></product>
</client>
Line: 2
Char: 10691
Code: 0
URI: http://xxxx:10270/...include/js/jquery.js

      

error function:

.error(function() {
    if (jqxhr.responseText == 'INVALID_SESSION') {
        alert("Your Session has been timed out");
        window.location.replace(communities);
    } else {
        alert("Error while getting xml from server");
        var xml=StringtoXML(jqxhr.responseText);
        var csmXmlDoc = $.parseXML( jqxhr.responseText ),
        $csmxml = $( csmXmlDoc ),
        $csmTitle = $csmxml.find("product").children("version");

        alert($csmTitle.text()+", "+$(xml).find("product").children("version").text());
        //goToHomePage();
    }
})

      

+3


source to share





All Articles