Tutorial :What am I doing wrong that I can't get JQuery to read my xml file into a DDL?


Trying to load data into a drop down list when a user selects one of two radio buttons. the bookGenres.xml file is in the same directory as my script. I'm out of ideas.


<?xml version="1.0" encoding="utf-8" ?>  <Genres>    <Fiction>      <book>Sci-Fi</book>      <book>Fantasy</book>      <book>Horror</book>      <book>Romance</book>      <book>Detective</book>    </Fiction>    <NonFiction>      <book>Autobiography</book>      <book>Philosophy</book>      <book>Cooking</book>      <book>Historic</book>      <book>Teaching</book>    </NonFiction>  </Genres>  


$('#rblGenre').click( function() {          $('#ddlSpecificGenre > option').remove();            $.ajax({              type: 'GET',              url: 'bookGenres.xml',              dataType: 'xml',              success: function( xml ) {                  $(xml).find( $(this).val() ).each( function() {                      var subgenre = $(this).find('book').text();                      $('#ddlSpecificGenre').append( "<option>" + subgenre + "</option>" );                  });              },              error: function() { alert( "WTF" ); }          });      });  



The most likely issue is that the bookgenres.xml might be in the same folder as the script, but is it in the same folder that the html page is that the jQuery is getting renered on?

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »