Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery将数据附加到选择框,数据来自webservice调用_Javascript_Jquery_Web Services - Fatal编程技术网

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

我不删除,因为这可能会帮助别人