更新时间:2022-12-04 20:12:41
如果你的方法不带参数,就不要在ajax调用上指定data属性
If your method takes no arguments, just don't specify the data property on the ajax call
<script>
$(function () {
$.ajax({
url: 'WebService.asmx/getList',
type: 'POST',
dataType: 'json', //make sure your service is actually returning json here
contentType: 'application/json',
success: function (data, status) {
//here data is whatever your WebService.asmx/getList returned
//populate your dropdown here with your $.each w/e
}
});
});
</script>
我也错了,但是你展示的WebService方法似乎不会返回JSON。我认为你必须序列化,或设置内容类型或类似的东西。 (自从我使用asmx类型服务以来一直沿着时间)
Also I could be wrong, but the WebService method you showed, doesn't look like it will return json. I think you will have to serialize, or set the content type or something similar. (Been along time since I've used the asmx type services)