title: Jquery Autocomplete - JSON.Parse error
body: <p>I'm trying to implement this web api autocomplete in a standard mvc app.
  <a href="http://techbrij.com/987/jquery-ui-autocomplete-asp-net-web-api" rel="nofollow noreferrer">http://techbrij.com/987/jquery-ui-autocomplete-asp-net-web-api</a></p>
  
  <p>Here's a screen grab from Firebug <a href="http://sdrv.ms/N0WkHP" rel="nofollow noreferrer">http://sdrv.ms/N0WkHP</a><br>
  <img src="https://i.stack.imgur.com/BOGw4.jpg" alt="enter image description here"></p>
  
  <p>I've created a controller method and added the jquery script, but I keep getting a 'JSON.parse: unexpected character' error. I don't see any unusual characters in my data.</p>
  
  <pre><code>$(document).ready(function () {
  $('#txtSearch3').autocomplete({
      source: function (request, response) {
          $.ajax({
              url: '/home/Get',
              type: 'GET',
              cache: false,
              data: request,
              dataType: 'json',
              success: function (json) {
                  // call autocomplete callback method with results
                  response($.map(json, function (name, val) {
                      return {
                          label: name,
                          value: val
                      }
                  }));
              },
              error: function (XMLHttpRequest, textStatus, errorThrown) {
                  //alert('error - ' + textStatus);
                  console.log('error', textStatus, errorThrown);
              }
          });
      },
      minLength: 2,
      select: function (event, ui) {
          alert('you have selected ' + ui.item.label + ' ID: ' + ui.item.value);
          $('#txtSearch3').val(ui.item.label);
          return false;
      }
  })
  });
  </code></pre>
  
  <p>// my controller code</p>
  
  <pre><code> public IDictionary&lt;int, string&gt; Get(string term)
      {
          using (myEntities context = new myEntities())
  
          {
              return context.Categories1.Where(x =&gt; x.CategoryName.Contains(term)).ToDictionary(x =&gt; x.CategoryId, x =&gt; x.CategoryName);
          }
  
      }
  </code></pre>