Forum Moderators: open

Message Too Old, No Replies

problem in AJAX using in FIREFOX

"[Object HTML Collection] " appears in firefox using AJAX

         

zangs

5:18 am on May 18, 2006 (gmt 0)

10+ Year Member



Hello ALll,

I got one object [object HTL collection], when i try to fetch the xmo node data from javascript.

Below is code for object which i have created,

//Firefox
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.overrideMimeType("application/xml");
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange=handleHttpResponse;
xmlhttp.send(null);
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if (xmlhttp)
{
xmlhttp.open("GET",url,true)
xmlhttp.onreadystatechange=handleHttpResponse;
xmlhttp.send();
}
}

I got successfully xml data by "xmlhttp.responseText"

But when i try to fetch data by
xmlhttp.responseXML.getElementsByTagName("id"), it returns [Object HTML collection] and when i use xmlhttp.responseXML.getElementsByTagName("id").length, it returns "null".

Anyone here can help me?

Thnx in advance

regrds,
Zangs

jshanman

1:14 pm on May 18, 2006 (gmt 0)

10+ Year Member



what does your xml look like? Can you paste one record (if it's not too long)?

- JS

zangs

2:13 pm on May 18, 2006 (gmt 0)

10+ Year Member



thnx for supporting,

<?xml version="1.0" encoding="iso-8859-1"?>
<list>
<iarticleid>12</iarticleid>
<itimecreated>17 days ago</itimecreated>
<varticleurl>http://www.rawstory.com/news/2006/Penny_costs_more_than_cent_to_0421.html</varticleurl>
<varticletitle>A penny actually costs 1.4 cents to produce</varticletitle>
<itotalrating>3</itotalrating>
<tdescription>The U.S. government is currently wrestling with the problem</tdescription>
<itotalcomments>0</itotalcomments>
<artrated>No</artrated>
<iuserid>1</iuserid>
<vusername>zangs</vusername>
<vfirstname>Michel</vfirstname>
<vlastname>Clerk</vlastname>
<viconimage>.</viconimage>
<icommenttorttype>.1</icommenttorttype>
<etargetwindow>.New</etargetwindow>
<eprofanityfilter>.</eprofanityfilter>
<icategoryid>1</icategoryid>
<vcategoryname>Headlines</vcategoryname>
</list>

this is my xml..

give me suggestion

regards,
Zangs

jshanman

2:26 pm on May 18, 2006 (gmt 0)

10+ Year Member



According to your sample XML,
xmlhttp.responseXML.getElementsByTagName("id")
will return an empty object because there are no <id> tags...

The closest thing I saw was: iuserid
so you would use: xmlhttp.responseXML.getElementsByTagName("iuserid") to get all iuserid tags...

Am I missing something else?

- JS

bedlam

2:29 pm on May 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But when i try to fetch data by
xmlhttp.responseXML.getElementsByTagName("id"), it returns [Object HTML collection] and when i use xmlhttp.responseXML.getElementsByTagName("id").length, it returns "null".

There is no tag anywhere in your xml sample named 'id'.

-b

zangs

2:30 pm on May 18, 2006 (gmt 0)

10+ Year Member



hello

i used "id" for testing, actually in my script i have used "iarticleid" replace of "id"..

thnx for replying
regards,
Zangs

zangs

5:48 am on May 19, 2006 (gmt 0)

10+ Year Member



Hello friends,

But when i try to fetch data by
xmlhttp.responseXML.getElementsByTagName("iarticleid"), it returns [Object HTML collection] and when i use xmlhttp.responseXML.getElementsByTagName("iarticleid").length, it returns "null".

Regards,
zangs