jquery不会出错或成功

与此相关: 如何将自动完成function连接到文本框?

我试图将自动完成(从jquery ui)链接到文本框。 我有以下内容:

$("#txtTags").autocomplete({ minLength: 0, source: function(request, response) { $.ajax({ type: "POST", url: "GetTags.asmx/GetTags", dataType: "xml", contentType: "text/xml; charset=utf-8", success: function(xml) { alert("hi"); // Completion logic goes here }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }, }); 

为什么我没有从成功函数或错误函数中获得alert ? 我必须使用dataType XML,因为我在一个古老的.net 1.1应用程序中当时不支持json / jsonp(2002/2003)。 GetTags.asmx是我的Web服务方法。 但是当我输入文本框时,我当然没有得到任何错误,也没有得到自动完成选择。

更新:

修复了成功问题所以我确实得到了成功函数,问题是我的自动完成文本框怎么还是空的呢? 在我在这个问题顶部发布的第一个链接中,我已经从数据库中获取了自动完成数据,我将其存储为字符串数组,并将其返回到我的webmethod中。 我必须在jquery中做什么来获取这些数据?

编辑2

这是从chrome / ie运行webservice(.asmx)文件后的xml文件:

 This XML file does not appear to have any style information associated with it. The document tree is shown below.  .net .net-1.1 3g 6283 7641 8-id 80070005 accounts actions activation active-directory active-directory ad addin adp adp-tlm-interface adptlm adupdater ajax  

从xml中创建数组并将其传递给响应,如下所示 –

  success: function(xml) { var data = []; $(xml).find('string').each(function(){ data.push($(this).text()); }); response(data); }, 

使用source选项的函数时,最终必须将数组传递给响应方法。

 source: function(request, response) { ... response(thearrayofdata); ... }