Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    parentNode.childNodes.length is not working in IE

    Hello All,

    parentNode.childNodes.lenght is not working in IE for me..But it works like a gem in firefox.
    Please can any one help me

    Here is my xml which is getting form a Java Program ..I am using as a Ajax Call

    XMl Response
    ------------
    Code:
    <xml version="1.0">
    <EMPLOYEES>
    <EMPLOYEE>
            <VALID>true</VALID>
            <NAME>Ajay.Maruvada</NAME>
           <EMPID>903</EMPID>
    </EMPLOYEE>
    <EMPLOYEE>
           <VALID>true</VALID>
           <NAME>Ajay.Nuda</NAME>
           <EMPID>2014</EMPID>
    </EMPLOYEE>
    <EMPLOYEE>
           <VALID>true</VALID>
           <NAME>Ajay.john</NAME>
           <EMPID>1725</EMPID>
    </EMPLOYEE>
    <EMPLOYEE>
          <VALID>true</VALID>
          <NAME>Ajay.Tummapala</NAME>
          <EMPID>2122</EMPID>
    </EMPLOYEE>
    <EMPLOYEE>
          <VALID>true</VALID>
           <NAME>Ajay.paden</NAME>
          <EMPID>2052</EMPID>
    </EMPLOYEE>
    </EMPLOYEES>
    </xml>


    Here is my Javascript which i am using to parse it
    -------------------------------------------------
    Code:
     var employees = responseXML.getElementsByTagName("EMPLOYEES")[0];
        var k = employees.childNodes.length; //  here i am getting error as Object required
        alert(k);
        if (employees.childNodes.length > 0) {
    Appriciate fast response

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,901
    Thanks
    56
    Thanked 543 Times in 540 Posts
    have you uploaded your page or are you testing locally? which version of IE?

  • #3
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Testing in my local system..I am using IE 8..

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,901
    Thanks
    56
    Thanked 543 Times in 540 Posts
    you can't do AJAX calls locally in IE the way you can with firefox. Either upload it or (maybe, I'm not sure) see if you can change your security settings in IE

  • #5
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the same functionality i am able to do and its working well in my IE as well..But this one i am getting this error in my console and stoping the whole script in exceuting

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Try this:
    Code:
    var employees = responseXML.documentElement;
    Note that childNodes include the text nodes (whitespaces are considered text nodes) so you will get more childNodes length than you expected.
    So it is preferred to get the EMPLOYEE nodes using getElementsByTagName.

    Code:
    var employees = responseXML.documentElement;
    var employeeList = employees.getElementsByTagName('EMPLOYEE');
    if (employeeList.length > 0) {
        //...
    }


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •