Hello sirs,
I am trying to send a POST request to a webservice on the click of a
button. This will return me an XML document with a list of combo box
items.
The problem: in FIREFOX, when the get the XmlDocument from the
XmlHttpRequest object, I can't access its contents. I keep getting
empty strings and "null".
This is my code:
---
function GetComboBoxItem s(p_strType, p_strCode)
{
var objParameters = new Array();
objParameters[0] = p_strType;
objParameters[1] = p_strCode;
var objHttpRequest =
SendRequest("/MeuWebService/MyWebService.as mx/GetComboBoxItem s",
objParameters);
alert(objHttpRe quest.responseT ext); // alerts the XML doc (see
below)
/*
this is the XML document:
<?xml version="1.0" enconding="utf-8"?>
<ReturnDocument >
<ComboItem>
<Key>1</Key>
<Description> My first item</Description>
</ComboItem>
<ComboItem>
<Key>2</Key>
<Description> My second item</Description>
</ComboItem>
</ReturnDocument>
*/
alert(objHttpRe quest.responseX ML); // alerts '[object XMLDocument]'
var XmlDoc = objHttpRequest. responseXML;
var arrTemp =
XmlDoc.document Element.getElem entsByTagName(" ComboItem");
alert(arrTemp.l ength); // alerts '2'
// show contents (Firefox)
for(var i = 0; i < arrTemp.length; i++)
{
alert(arrTemp[i].childNodes[0].nodeValue); // alerts empty string
alert(arrTemp[i].childNodes[1].nodeValue); // alerts 'null'
}
/*
// show contents (IE) - works perfectly
for(var i = 0; i < arrTemp.length; i++)
{
alert(arrTemp[i].childNodes[0].text);
alert(arrTemp[i].childNodes[1].text);
alert(arrTemp[i].childNodes[2].text);
} */
}
---
I searched everywhere for a logic explanation, but couldn't find any.
In IE it works perfectly. What am I doing wrong?
TIA,
Leonardo