transportXML returns null?

0 views
Skip to first unread message

AlexK

unread,
Sep 27, 2007, 6:39:01 PM9/27/07
to Ruby on Rails: Spinoffs
Hi,

I want to load an XHTML file into DOM. I issue Ajax.Request and on
success do:
var response=transport.responseXML

Response is null. On the other hand:
var response=transport.responseText; // has the data.

Why is response=transport.responseXML returns null?

Here is the code:

function display() {
url = "http://" + location.hostname + port + "/fusion/
restlet/";
url = url + "engines" + sServer;
new Ajax.Request(url,
{
method:"get",
contentType:"application/xhtml+xml",
onSuccess: function(transport) {


var response = transport.responseXML; // null ?
//var response = transport.responseText; // OK

alert("after response=" + response);
if (response != null) {
alert("b=" +
response.getElementById('lastUpdate').innerHTML); // this never works
}
else
alert("onSuccess, responseXML is null");
},
onFailure: function(){ alert("Cannot get data from server:
" + location.host) }
});
}

Tobie Langel

unread,
Sep 27, 2007, 7:16:52 PM9/27/07
to Ruby on Rails: Spinoffs
You have to set a correct content-type (application/xml).

Regards,

Tobie

Tobie Langel

unread,
Sep 27, 2007, 7:16:52 PM9/27/07
to Ruby on Rails: Spinoffs
You have to set a correct content-type (application/xml).

Regards,

Tobie

On Sep 28, 12:39 am, AlexK <alexkoif...@gmail.com> wrote:

AlexK

unread,
Sep 28, 2007, 12:25:08 AM9/28/07
to Ruby on Rails: Spinoffs
Hi, this:
contentType: "application/xml"

did not change anything. ANy other ideas? Thanks.

> > }- Hide quoted text -
>
> - Show quoted text -

AlexK

unread,
Sep 28, 2007, 1:48:33 AM9/28/07
to Ruby on Rails: Spinoffs
This is what I added to the XHTML file that I get:

<meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" />

and this:

new Ajax.Request(url,
{
method:"get",

contentType:"text/xml",
onSuccess: function(transport) {

And I still get null: var response =
transport.responseXML;

Thanks!

Matt Foster

unread,
Sep 28, 2007, 2:59:56 PM9/28/07
to Ruby on Rails: Spinoffs
I use the following code in PHP to make sure my output is interpreted
as XML

header("Content-Type: text/xml");

and this code for ColdFusion.

<cfheader charset="utf-8" name="Content-type" value="text/xml">


Cheers,
Matt

Reply all
Reply to author
Forward
0 new messages