perhaps you have something like this
on200: function(xhr) {
someFunction(xhr.responseText);
}
To access the responseXML you should be able to do
on200: function(xhr) {
someFunction(xhr.responseXML);
}
I have never used this however as I use JSON as my transport format.
Peter
The xhr object sent to the callback functions of a Fork Ajax request
is just a regular browser xhr object. It is not wrapped or anything
special. For this reason I think the question is not actually
Fork-specific but rather a general xhr/xml question. Are you sure your
xml document is truly a valid xml document?
Peter
> ok, this is what is returned by the forkajax
I think you mean returned by the server.
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <gallery>
> <gxml_id>id_less</gxml_id>
> <gxml_ownerid>God Father</gxml_ownerid>
> <gxml_name>Antoine</gxml_name>
> <gxml_share>Hustlenomics Inc.</gxml_share>
> </gallery>
>
> but when i try to access the document with the below js script my
> firebug gives me the xmlDoc 'has no properties' error...
> xmlDoc=o.responseXML;
> document.getElementById("gala_id").innerHTML=
> xmlDoc.getElementsByTagName("gxml_id")[0].childNodes[0].nodeValue;
> document.getElementById("gala_name").innerHTML=
> xmlDoc.getElementsByTagName("gxml_name")[0].childNodes[0].nodeValue;
> document.getElementById("gala_share").selected=
> xmlDoc.getElementsByTagName("gxml_share")
> [0].childNodes[0].nodeValue;
>
> bloew are the div's to be filled
> <div id="gala_name">dummy</div>
> <div id="gala_id">dummy</div>
> <div id="gala_share">dummy</div>
>
> what could be the problem?
I'm not sure. I just tried an experiment successfully.
I created a new Ruby on Rails application
$ rails xmlExpt
$ cd xmlExpt
$ mongrel_rails start xmlExpt
I edited the file xmlExpt/public/index.html to be the following
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>test page</title>
<script type="text/javascript" src="javascripts/ajax.js"></script>
<script type="text/javascript">
var go = function() {
console.log("going");
new FORK.Ajax('GET', '/some.xml', {
onComplete: function(xhr) {
console.log("returned");
console.log(xhr.responseXML);
}
});
console.log("gone");
};
</script>
</head>
<body>
<p style="font-size:500%"><a href="#"
onclick="try{go();}catch(e){console.log(e);}return false;">go</a></p>
</body>
</html>
Then I added a file xmlExpt/public/some.xml with this content.
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
I pointed my browser to http://loccalhost:3000/ and pressed the big
"go" link. When I looked in the Firebug console I could see the xml
document was returned.
Just as an extra check I ran curl to make sure the content-type header
of the xml response was correct
$ curl -I http://localhost:3000/some.xml
HTTP/1.1 200 OK
Connection: close
Date: Fri, 23 May 2008 17:20:22 GMT
ETag: "4836fae7-a1-d6cdde"
Last-Modified: Fri, 23 May 2008 17:12:07 GMT
Content-Type: text/xml
Content-Length: 161
It looks good with "text/xml"
Please give this example a try as I have described.
Peter