<mjesta>
<mjesto>Zagreb</mjesto>
<mjesto>Split</mjesto>
<mjesto>Ploce</mjesto>
<mjesto>Pula</mjesto>
<mjesto>Pazin</mjesto>
<mjesto>Daruvar</mjesto>
<mjesto>Bjelovar</mjesto>
<mjesto>Slunj</mjesto>
<mjesto>Osijek</mjesto>
<mjesto>Virovitica</mjesto>
</mjesta>
XML file i'm reading
$(document).ready(function() {
$(function() {
$.ajax({
url: "location of xml...",
type: "GET",
dataType: "xml",
success: function(gradovi) {
$(gradovi).find("mjesta").each(function() {
$(this).find("mjesto").each(function() {
$red = "<option value=" + $(this) + ">";
$("#mjesta").append($red);
});
});
}
});
});
});
Jquery code
<input list="mjesta" name="mjesta">
<datalist id="mjesta">
</datalist>
HTML where i'm inserting the data
How do I read this xml file and insert data into my datalist?
I have no experience with xml so I dont know how to get the word that is inside <mjesto>WORD</mjesto>
I'm pretty sure the problem is here:
$red = "<option value=" + $(this) + ">";