3 Replies Latest reply on Feb 19, 2010 7:11 AM by M.R.Biesheuvel

    XML data via JS not showing in I.E.?

    keithwoods Level 1

      Hi there,

      I'm using Javascript to get the xml data and display it on the XHTML page.

      This works fine in all the latest versions of Firefox, Chrome, Safari and Opera....but as per usual not in Internet Explorer.

       

      UPDATE: forgot to mention.....I'm testing this from my machine and not live.   Could this be a reason why it's not working on I.E. because the files are on my computer and not on a server???

      Any advice greatly appreciated! HTML Code below...

       

      <div id="testimonials">
             
                     
      <h1>Testimonials</h1>
             
                     
      <script type="text/javascript">
                                     
      if (window.XMLHttpRequest)
                                       
      {
                                        xhttp
      =new XMLHttpRequest();
                                       
      }
                                     
      else // Internet Explorer 5/6
                                       
      {
                                        xhttp
      =new ActiveXObject("Microsoft.XMLHTTP");
                                       
      }
                                      xhttp
      .open("GET","resources/testimonials.xml",false);
                                      xhttp
      .send("");
                                      xmlDoc
      =xhttp.responseXML;
                                     
                                     
      var x=xmlDoc.getElementsByTagName("testimonial");
                                     
      for (i=0;i<x.length;i++)
                                       
      {
                                        document
      .write("<p>");
                                        document
      .write(x[i].getElementsByTagName("text")[0].childNodes[0].nodeValue);
                                        document
      .write("</p>");
                                        document
      .write("<p>");
                                        document
      .write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
                                        document
      .write("</p>");
                                       
      }
                             
      </script>
                                       
           
      </div> <!-- END of DIV Testimonials -->

       

       

       

       

      Cheers!

        • 1. Re: XML data via JS not showing in I.E.?
          M.R.Biesheuvel Level 3

          What part doesn't work, the ajax call or the xml manipulatation?

           

          I've attached a javascripot file for making an ajax call or load a xml file directly synchrone or asynchrone

          • 2. Re: XML data via JS not showing in I.E.?
            keithwoods Level 1

            Thanks for the attachment, I'll try and make some sense of it- although I'm not very good with JS!

             

            I think it's the XML HTTP Request part that isnt working.

             

            It all works fine in all the major browsers except I.E.?

             

            Not sure if you've seen my update but does it matter that I'm testing the site from my machine and not on a server?  Does I.E. expect all the files (or the XML file at least) to be sitting on a server to make the XMLHttpRequest() work?

             

             

            • 3. Re: XML data via JS not showing in I.E.?
              M.R.Biesheuvel Level 3
              I'm testing this from my machine and not live.   Could this be a reason why it's not working on I.E. because the files are on my computer and not on a server???

              No, remember that if you make an xmlhttprequest you'r program isn't talking to the server but to the browser and then the browser makes a request to the server. But you forgot one way of making an xmlhttprequest object in IE as you can see in the file I've attached in my previous answer.

               

              Now if a file doesn't exist the call's response will allways be htpp error 404 that's returned by response.statuscode