Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery autocomplete JSON return result from webservice but it is not showing in dropdownlist
    text
    copied!<p>I do not know what is wrong with this code. alert shows that data has returned from web service but auto-complete still not showing data. I am using ASP.net 2.0 and google jquery link</p> <p> </p> <pre><code> $(document).ready(function() { $.ajax({ type: "POST", url: "http://localhost/WebService/Service.asmx/getlist2", dataType: "json", data: "{}", contentType: "application/json; charset=utf-8", success: function(data) { alert("getlist 2"); alert(data); $('#project1').autocomplete({ minLength: 2, source: data, focus: function(event, ui) { $('#project1').val(ui.item.TagName); alert(ui.item.TagName);//no alert is fired here return false; }, select: function(event, ui) { $('#project1').val(ui.item.TagName); //$('#selectedValue').text("Selected value:" + ui.item.TagID); return false; } }); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); }); </code></pre> <p>and web service method</p> <pre><code>[WebMethod] [System.Web.Script.Services.ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List&lt;Tag&gt; getlist2() { &lt;Tag&gt; tagscollection = new EntitiesCollection&lt;Tag&gt;(); ProcessTagList getlisttags = new ProcessTagList(); string strtag = ""; Tag tag = new Tag(); tag.TagName = strtag; tag.UniqueName = strtag; getlisttags.OTag = tag; getlisttags.Invoke(); tagscollection = getlisttags.OTagsCollection; ; List&lt;Tag&gt; a = new List&lt;Tag&gt;(); foreach(Tag tagc in tagscollection) { a.Add(tagc); } return a; } </code></pre> <p>data shown in firebug is:</p> <p>[{"__type":"myproject.Common.Tag","TagID":"21abf6b1-6d45-41e5-a39b-006e621eeb22","UniqueName":"dotnet","TagName":"dotnet","CreatedAt":"/Date(1255108286850)/"}]</p> <p>this jquery code shows dropdown list from the webservice used with first jquery example.</p> <pre><code>$("#tbAuto").autocomplete({ source: function(request, response) { $.ajax({ url: "http://localhost/myproject/Service.asmx/getlist2", data: "{}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", // dataFilter: function(data) { return data; }, success: function(data) { response($.map(data, function(item) { return { value: item.TagName } })) }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(errorTrown); } }); }, minLength: 0 }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload