Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My answer is built based on an asp.net 3.5 solution and jQuery 1.7.1 version assumption. Much has been already covered by other posters. Yours may vary by version. This is simply an attempt to put comments in an answer with a completed script and server side notes.</p> <p>Have you decorated your class thus:</p> <pre><code>[WebService(Namespace = "http://mysite.com/researcher_list/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] [ScriptService] public class researcher_list : WebService { </code></pre> <p>Decorate your method: (use the EnableSession IF you need that...)</p> <pre><code>[WebMethod(EnableSession = true)] public List&lt;DBResearcher.Summary&gt; FetchResList(string resName) { </code></pre> <p>cleanup of the client script:</p> <pre><code>$('input:text').autocomplete({ source: function(request, response) { var pString = '{ "resName": "' + request.term + '" }'; $.ajax({ url: "researcher_list.asmx/FetchResList", /* same root as the page? */ data: pString, dataType: "jsond", type: "POST", contentType: "application/json", /* simplify */ converters: { /* avoid the d or no d issue, works with 3.5 or prior this way */ "json jsond": function(msg) { return msg.hasOwnProperty('d') ? msg.d : msg; } }, success: function(data) { /* assumes data always returned and it IS called item in the JSON */ response($.map(data, function(item) { return { value: item.name, label: item.name }; })); }, minLength: 2, error: function(xhr, textStatus, errorThrown) { var errorMessage = "Ajax error: " + this.url + " : " + textStatus + " : " + errorThrown + " : " + xhr.statusText + " : " + xhr.status; if (xhr.status != "0" || errorThrown != "abort") { alert(errorMessage); } } }); } }); </code></pre> <p>IN ADDITION to the above, there are Web.config settings in asp.net that need set to get a web service to function - assumption here is you have done the research and have that working. IF NOT, suggestion is create a simple method that returns the current time as a string with NO parameters (data:"{}",) and get that via ajax to ensure it works before the complexity of the autocomplete is layered.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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