title: Retrieve and update data from SQL Server 2008 with AJAX/Jquery
body: <p>I am presently working on a new development and I really need my project to have the silky feel it requires, So I thought of using Ajax or jQuery to retrieve data from SQL Server  2008. I am new to JSON and its functions. </p>
  
  <p>Here is the html:</p>
  
  <pre><code>Enter Employee ID
  &lt;br /&gt;
  &lt;asp:TextBox ID="txtEmpId" runat="server"&gt;&lt;/asp:TextBox&gt;&amp;nbsp;
  &lt;br /&gt;
  &lt;input type="button" id="BtnSearch" runat="server" value="Search" /&gt;
  &lt;div id="emp" style="display: none; margin-top: 40px"&gt;
      ID:&lt;span id="txtId"&gt;&lt;/span&gt;&lt;br /&gt;
      Title:&lt;span id="txtTitle"&gt;&lt;/span&gt;&lt;br /&gt;
      Name:&lt;span id="txtName"&gt;&lt;/span&gt;&lt;br /&gt;
      Department:&lt;span id="txtDepartment"&gt;&lt;/span&gt;&lt;br /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The Ajax goes as thus:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function () {
  
      $("#MainContent_BtnSearch").click(function () {
  
          $("#emp").hide("slow");
  
          var empId = $("#MainContent_TxtEmpId").val();
          $.ajax({
              type: "GET",
              dataType: "json",
              contentType: "application/json",
              url: "",
              data: "{'employeeId': '" + empId.toString() + "'}",
              success: function (data) {
                  $("#txtId").html(data.d.ID);
                  $("#txtName").html(data.d.FullName);
                  $("#txtTitle").html(data.d.Title);
                  $("#txtDepartment").html(data.d.Department);
                  /// show employee details
                  $("#emp").show("slow");
              },
              error: function () {
                  alert("Error calling the web service.");
              }
           });
       });
  });
  </code></pre>
  
  <p></p>
  
  <p>Is there any way to make my code better in such a way that it gets data from the database in  SQL Server 2008 and also be able to update that record and save database changes.</p>