title: call webmethod with parameter from javascript using Json.Encode
body: <p>I have a <code>WebMethod</code>:</p>
  
  <pre><code>[WebMethod]
  public static string[] getDropDown(int idSpacies)
  {
      var raceList = from r in db1.breed where r.spaciesID == idSpacies select r;
      string[] temp = new string[raceList.Count()];
      int counter = 0;
  
      foreach (var item in raceList )
      {
          temp[counter] = item.name;
          counter++;
      }
      return temp;
  }
  </code></pre>
  
  <p>And JavaScript function:</p>
  
  <pre><code>function changeSpacies()
  {
      var temp = document.getElementById("selectpicker").value;
  
      var availableTags = @Html.Raw(Json.Encode(AlewetWeb.Areas.ClinicService.Controllers.BreedsController.getDropDown(temp)));
  
        $("#tags").autocomplete({
          source: availableTags
        });
  }
  </code></pre>
  
  <p>When I use <code>temp</code> variable as parameter in a <code>WebMethod</code>'s <code>getDropDown</code> call  I receive error </p>
  
  <blockquote>
    <p>temp doesn't exist in the current context</p>
  </blockquote>
  
  <p>How I can pass a JavaScript variable to <code>WebMethod</code>.</p>