L
leodippolito
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 GetComboBoxItems(p_strType, p_strCode)
{
var objParameters = new Array();
objParameters[0] = p_strType;
objParameters[1] = p_strCode;
var objHttpRequest =
SendRequest("/MeuWebService/MyWebService.asmx/GetComboBoxItems",
objParameters);
alert(objHttpRequest.responseText); // 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(objHttpRequest.responseXML); // alerts '[object XMLDocument]'
var XmlDoc = objHttpRequest.responseXML;
var arrTemp =
XmlDoc.documentElement.getElementsByTagName("ComboItem");
alert(arrTemp.length); // alerts '2'
// show contents (Firefox)
for(var i = 0; i < arrTemp.length; i++)
{
alert(arrTemp.childNodes[0].nodeValue); // alerts empty string
alert(arrTemp.childNodes[1].nodeValue); // alerts 'null'
}
/*
// show contents (IE) - works perfectly
for(var i = 0; i < arrTemp.length; i++)
{
alert(arrTemp.childNodes[0].text);
alert(arrTemp.childNodes[1].text);
alert(arrTemp.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
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 GetComboBoxItems(p_strType, p_strCode)
{
var objParameters = new Array();
objParameters[0] = p_strType;
objParameters[1] = p_strCode;
var objHttpRequest =
SendRequest("/MeuWebService/MyWebService.asmx/GetComboBoxItems",
objParameters);
alert(objHttpRequest.responseText); // 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(objHttpRequest.responseXML); // alerts '[object XMLDocument]'
var XmlDoc = objHttpRequest.responseXML;
var arrTemp =
XmlDoc.documentElement.getElementsByTagName("ComboItem");
alert(arrTemp.length); // alerts '2'
// show contents (Firefox)
for(var i = 0; i < arrTemp.length; i++)
{
alert(arrTemp.childNodes[0].nodeValue); // alerts empty string
alert(arrTemp.childNodes[1].nodeValue); // alerts 'null'
}
/*
// show contents (IE) - works perfectly
for(var i = 0; i < arrTemp.length; i++)
{
alert(arrTemp.childNodes[0].text);
alert(arrTemp.childNodes[1].text);
alert(arrTemp.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