Announcement Announcement Module
Collapse
No announcement yet.
loading xml in JavaScript not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • loading xml in JavaScript not working

    I've got some setting somewhere that must be missing because I just can't get an xml file to load via JavaScript - I'm using the Spring & Tiles framework

    example xml file:
    Code:
    <?xml version="1.0" encoding="ISO8859-1" ?>
    <NewDataSet>
        <CD>
            <Name>Music</Name>
        </CD>
        <CD>
            <Name>Politics</Name>
        </CD>
        <CD>
            <Name>Shopping</Name>
        </CD>
    </NewDataSet>
    jsp tile:
    Code:
     
    <script type="text/javascript"><!--
    /* <![CDATA[ */
    var xmlDoc;
    var genrename;
    window.onload=loadXmlDoc;
    
    function loadXmlDoc()
    {    
    	  if (window.ActiveXObject)
    	    {
    	        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    	        xmlDoc.async=false;
    	        xmlDoc.load("/tiles/search_bar/music.xml");
    	        LoadOptions();    
    	    }
    	    else if (document.implementation && document.implementation.createDocument)    
    	    {
    	        xmlDoc = document.implementation.createDocument("","",null);
    	        xmlDoc.onload = LoadOptions();
    	        xmlDoc.load("/tiles/search_bar/music.xml");
    	    }
    }
    
    function LoadOptions()
    {
      genrename = xmlDoc.getElementsByTagName("Name");
      for (var i=0; i<genrename.length; i++)
      {
          document.forms['genreform'].genre.options[i] = new Option(genrename[i].firstChild.nodeValue,genrename[i].firstChild.nodeValue);
      }
    }
    
    /* ]]> */
    --></script>
    
    <form name="genreform">
        <select name="genre" >
          <option value="Test"> Testing</Option>
        </select>
    </form>
    <div id = "box" style= "background:yellow;width:320px;padding:5px"> </div>

    I've tried changing the xml location from "/tiles/search_bar/music.xml" to just about everywhere on the server, but always get the same results.
Working...
X