Ajax和Grails渲染

I'm trying to read XML with AJAX, all the data are took from a well formed XML file and then are sended to client page through AJAX. But xmlhttp.responseXML always remains unusable.

Here's my controller :

def fileGetter = {
    if (params.fileId) {
        try {
            String resultStr = fileManipulatorService.fileProvider(params.fileId).getText()
            println resultStr
            render(text: resultStr, contentType: "text/xml", encoding: "ISO-8859-1")
            response.sendError(200)
       }
    }
}

resultStr contains the proper xml, on my webpage xmlhttp response text contains the correct xml data too while xmlhttp response xml contains nothing. How can I send true xml data to my client page and exploit it? I need too work with an XML response. (I tried to send a new xml object created from the string, I tried to return the original file, but none of these methods worked) (I'm using Chrome)

Thank you

You may try render resultStr as XML

It should work, thougt I don't really like these converters.

I'm not sure if this is the cause of your problem, but this code doesn't make any sense

render(text: resultStr, contentType: "text/xml", encoding: "ISO-8859-1")
response.sendError(200)

Grails does not return after executing render so it will execute the response.sendError after returning valid data. Replace these lines with

render(text: resultStr, contentType: "text/xml", encoding: "ISO-8859-1")