I am working on a project and I am not sure what to do next. My goal is to populate a dropdown-menu with a xml file. The menu is based on 4 steps. "Fylke" "Kommune" "Kategori" "Dato". Right now I get the xml to feed data to "Fylke" with the example under. The next step is to populate "Kommune" with Halden when the user choose Akershus from the "Fylke" menu.
Here is the XML:
<arrangement>
<fylke name="Akershus">
<kommune name="Halden">
<arrangement id="570215856">
<kategori>Moro</kategori>
<dato>2013-10-10</dato>
</arrangement>
Here is the Script: (This is feeding "fylke" to the menu at the moment.)
$(document).ready( function() {
arrangementer();
fetch();
});
/*function fetch() {
setTimeout( function() {
arrangementer();
fetch();
}, 100);
}*/
function arrangementer() {
$.ajax({
url: "arrangementer.xml",
dataType: "xml",
success: function(data) {
$('ul').children().remove();
$(data).find("arrangement fylke").each( function() {
var info = '<a href="#">'+$(this).attr("name")+'</a>';
$('ul').append(info);
});
},
error: function() { $('ul').children().remove();
$('ul').append("<li>There was an error!</li>"); }
});
}