I created my first AJAX application and everything was going great when I used responseText to retrieve my data.
I decided to switch to XML output and now I receive "Object Null" error when I alert my output. When I change it back to responseText I can see the XML output.
Can someone tell me what is wrong?
[HIGHLIGHT="JavaScript"]
function stateChanged()
{
if ((xmlRT.readyState==4)&&(xmlRT.status == 200))
{
var xmlobj=xmlRT.responseXML;
alert(xmlobj);
}
}
[/HIGHLIGHT]
There can be several reasons for this but one of the most common is that the content you are reading is not set to text/html.
In PHP you set it:
[highlight="php"]
header("Content-type: text/xml");
[/highlight]
An easy way to tell is to load your output into your browser. It should appear in XML format (with a tree like structure) and not just plain text.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks