Y
Yorian
Hi,
Another problem another question (as usual). I want to retrieve data
through
ajax, within the data there is some javascript which needs to be used
(I
figured that one out using eval ()). The problem is that the script I
run
(and get from the response) needs to use the response itself.
Now after some testing I came to this:
To make things more clear, some code:
the function which handles the response:
function getPageData(http_request) {
try {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var xml = http_request.responseXML;
var script =
xml.getElementsByTagName('evalscript')[0].childNodes[1].nodeValue;
eval(script);
} else {
alert('There was a problem with the request.');
}
}
}
catch( e ) {
alert('Caught Exception: ' + e.description);
}
}
the response send to this function:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<evalscript>
<![CDATA[
document.getElementById('extendedinfo_form').innerHTML =
xml.getElementsByTagName('output')[0].childNodes[0].nodeValue;
]]>
</evalscript>
<output>
<b>surf</b>
</output>
</root>
Now the questions:
1: I tried to use real html tags within <output> and </output> and get
the contents using innerHTML like so:
xml.getElementsByTagName('output')[0].innerHTML;
But that will return undefined. So can anyone tell me why that doesn't
work and why I need to change the < and > to < and >
2: What I have got now works in Firefox but not in Internet Explorer,
in which it returns an error:
Caught Exception: object expected
Can anybody help me out?
cheers,
Yorian
Another problem another question (as usual). I want to retrieve data
through
ajax, within the data there is some javascript which needs to be used
(I
figured that one out using eval ()). The problem is that the script I
run
(and get from the response) needs to use the response itself.
Now after some testing I came to this:
To make things more clear, some code:
the function which handles the response:
function getPageData(http_request) {
try {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var xml = http_request.responseXML;
var script =
xml.getElementsByTagName('evalscript')[0].childNodes[1].nodeValue;
eval(script);
} else {
alert('There was a problem with the request.');
}
}
}
catch( e ) {
alert('Caught Exception: ' + e.description);
}
}
the response send to this function:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<evalscript>
<![CDATA[
document.getElementById('extendedinfo_form').innerHTML =
xml.getElementsByTagName('output')[0].childNodes[0].nodeValue;
]]>
</evalscript>
<output>
<b>surf</b>
</output>
</root>
Now the questions:
1: I tried to use real html tags within <output> and </output> and get
the contents using innerHTML like so:
xml.getElementsByTagName('output')[0].innerHTML;
But that will return undefined. So can anyone tell me why that doesn't
work and why I need to change the < and > to < and >
2: What I have got now works in Firefox but not in Internet Explorer,
in which it returns an error:
Caught Exception: object expected
Can anybody help me out?
cheers,
Yorian