title: how to call web service in ajax properly?
body: <p>ok, here is what i am trying to do, i want to get all user from active directory and put it in the list,so i would call a web service from ajax, to get all user and put it the list string, and later on i want to use jquery autocomplete in the textbox base on list of user which i got before.</p>
  
  <p>this is what i do :</p>
  
  <pre><code>  $(document).ready(function () {
  
              // Load data then initialize plugin:
              $.ajax({
                  url: '/SvcADUser.asmx/GetADUserList',
                  dataType: 'json'
              }).done(function (source) {
  
                  var countriesArray = $.map(source, function (value) { return { value: value }; }),
                      countries = $.map(source, function (value) { return value; });
  
                  // Setup jQuery ajax mock:
                  $.mockjax({
                      url: '*',
                      responseTime: 200,
                      response: function (settings) {
                          var query = settings.data.query,
                              queryLowerCase = query.toLowerCase(),
                              suggestions = $.grep(countries, function (country) {
                                  return country.toLowerCase().indexOf(queryLowerCase) !== -1;
                              }),
                              response = {
                                  query: query,
                                  suggestions: suggestions
                              };
  
                          this.responseText = JSON.stringify(response);
                      }
                  });
  
  
  
                  // Initialize autocomplete with local lookup:
                  $('#MainCT_dtvJobVac_PIC').autocomplete({
                      lookup: countriesArray,
                      onSelect: function (suggestion) {
                          $('#selection').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
                      }
                  });
  
              });
  
          }());
  
      }());
  </code></pre>
  
  <p>but this throw me an error, <code>"NetworkError: 500 Internal Server Error - http://localhost:60525/SvcADUser.asmx/GetADUserList"</code>, if i change the url to SvcADUser.asmx, it does not give an error, but give me no result.</p>
  
  <p>what i do wrong here? btw here is my web service code :</p>
  
  <pre><code> [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      [System.Web.Script.Services.ScriptService]
      public class SvcADUser : System.Web.Services.WebService
      {
          [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
          [WebMethod]
          public List&lt;string&gt; GetADUserList(string keyword)
          {
              List&lt;string&gt; alluser = new List&lt;string&gt;();
  
              using (var context = new PrincipalContext(ContextType.Domain, "weekendinc.com"))
              {
                  using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
                  {
                      foreach (var result in searcher.FindAll())
                      {
                          DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
  
                          alluser.Add((string)de.Properties["samAccountName"].Value);
                      }
                  }
              }
  
              var filtereduser = alluser.Where(usr =&gt; usr.ToLower().StartsWith(keyword.ToLower()));
  
              return filtereduser.ToList();
          }
  
      }
  </code></pre>