otnj2ee
01-16-2008, 10:29 PM
from javascript made AJAX call-->
-->Server side:
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><options><option>Test</option></options>";
response.getOutputStream().println(xmlString);
-->Now back to javascript:
var optsArray = ajaxRequest.responseXML.getElementsByTagName('option');
for(var i=0; i<optsArray.length; i++) {
...
...
It works fine. Since it returns a string from server side I would assume I should use ajaxRequest.responseText, and ajaxRequest.responseXML should not work. But in reality, ajaxRequest.responseXML works just fine.
Why and how does it (ajaxRequest.responseXML) work for a returned string?
Thanks
Scott
-->Server side:
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><options><option>Test</option></options>";
response.getOutputStream().println(xmlString);
-->Now back to javascript:
var optsArray = ajaxRequest.responseXML.getElementsByTagName('option');
for(var i=0; i<optsArray.length; i++) {
...
...
It works fine. Since it returns a string from server side I would assume I should use ajaxRequest.responseText, and ajaxRequest.responseXML should not work. But in reality, ajaxRequest.responseXML works just fine.
Why and how does it (ajaxRequest.responseXML) work for a returned string?
Thanks
Scott