I have this xml document:
message 1
Try this code:
$(document).ready(function() {
$.ajax({
type: "GET",
url: "numbers.xml",
dataType: "xml",
success: function(response) {
$('lesson', response).each(function() {
$("#dropdownlist").append($('<option />').text($(this).text()));
});
}
});
$("select").change(function() {
var str = '';
$(this).find(":selected").each(function() {
str += $(this).text() +' ';
});
$("#dropdownlist").val(str);
}).change();
});
You were attaching a change()
trigger to your element every time you looped.