title: jQuery Autocomplete with Name/Value pairs from ASMX via JSON
body: <p>I have two textboxes which I am trying to use for autocomplete. The source data for both is coming from an ASP.NET ASMX web service, returned in JSON format. I'm getting back a List where NameValue is defined as:</p>
  
  <p><code>public struct NameValue { public string Name; public string Value; }</code></p>
  
  <p>How can I parse this data such that the selected dropdown Name's Value can be stored away in a hidden field?</p>
  
  <p>Here is my code thus far when the page loads, and <code>msg.d</code> contains the JSON data (I see <code>msg.d[0].Name</code> and <code>msg.d[0].Value</code>)</p>
  
  <pre><code>$.ajax({
          type: "POST",
          url: '/Services/Team.asmx/GetClubTeams',
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(msg) {
            $('#&lt;%= txtFromTeam2.ClientID %&gt;, #&lt;%= txtToTeam2.ClientID %&gt;').autocomplete({
              source:msg.d
            });
          },
          error: function(xhr, msg) {
            alert(msg);
          }
        });
  </code></pre>