title: Calling Linq to SQL method in Web service with jQuery
body: <p>I have a test web service called: MySimpleService.svc with a method called:GetUserNamesByInitials. below is the Linq to SQL code:</p>
  
  <pre><code>[OperationContract]   
  public static string GetUserNamesByInitials(string initials)
  {
          string result = "";
  
          //obtain the data source
          var testDB = new TestDBDataContext();
  
          //create the query
          var query = from c in testDB.TestTables
                      where c.initials == initials
                      select c;
  
          //execute the query
          foreach (var c in query)
          {
              result = result + c.full_name;
          }
  
          return result;
  }
  </code></pre>
  
  <p>I have used that code in page behind and it works well. However when i try to call it using jQuery I don't get any result, no errors nothing. below is the code i use in jQuery:</p>
  
  <pre><code>$('#TextBox3').live('keydown', function(e) {
      var keyCode = e.keyCode || e.which;
  
      if (keyCode == 9) {
          e.preventDefault();
  
          //call function here
          $.ajax({
  
              type: "POST",
              url: "/MySimpleService.svc/GetUserNamesByInitials",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              data: '{"word":"' + $('#TextBox3').val() + '"}',
              success: function(data) {
  
                  $('#TextBox4').val(data.d);
  
  
              }
  
          });
  
  
      }
  
  
  });
  
  });
  </code></pre>
  
  <p>what I do is to type the user id in one textbox (TextBox3) and when I press the Tab key the result is shown in another textbox (TextBox4).
  The jQuery call works well with other methods that do not call the database, for example using this other web service method it works: </p>
  
  <pre><code>[OperationContract]
  public string ParameterizedConnectionTest(string word)
  {
      return string.Format("You entered the word: {0}", word);    
  }
  </code></pre>
  
  <p>However with the Linq method it just does not work. Maybe i am doing something wrong? thank you in advance.</p>