Javascript 使用jquery将数据附加到选择框,数据来自webservice调用
我有以下代码:Javascript 使用jquery将数据附加到选择框,数据来自webservice调用,javascript,jquery,web-services,Javascript,Jquery,Web Services,我有以下代码: $(document) .ready( function() { $.ajax({ type : "GET", url : "http://localhost:8080/RememberMeServer/rest/LifeEventService/events", dataType : "xml", suc
$(document)
.ready(
function() {
$.ajax({
type : "GET",
url : "http://localhost:8080/RememberMeServer/rest/LifeEventService/events",
dataType : "xml",
success : function(xml) {
$(xml).find('Event').each(function() {
var name = $(this).find('Text').text();
$('#droplistevents').append($('<option/>', {
value: name,
text : name
}));
});
},
error : function(xhr) {
alert(xhr.responseText);
}
});
});
它所做的是向在该地址上运行的Web服务发出get请求,并获取该地址内的数据
但不幸的是,我无法将该信息添加到id=droplistevents的html文件中的选择框中。
我做错了什么?这确实有效。我在调用这个的html页面中调用了错误的js 我不删除,因为这可能会帮助别人