title: Passing array of strings to webmethod with variable number of arguments using jQuery AJAX
body: <p>I'm trying to pass an array of string parameters to a C# ASP.NET web service using jQuery Ajax. Here is my sample web method. Note that the function accepts a variable number of parameters. I get a 500 Internal Server Error in Chrome's javascript console when I run the jquery. I'm using jquery 1.6.2 and .NET3.5</p>
  
  <pre><code>[WebMethod]
  public string Concat(params string[] arr)
  {
      string result = "";
      for (int i = 0; i &lt; arr.Length; i++)
      {
          result += arr[i];
      }
      return result;
  }
  </code></pre>
  
  <p>Here is the jquery:</p>
  
  <pre><code>$(document).ready(function() {
  
      var myCars=new Array(); 
      myCars[0]="Saab";      
      myCars[1]="Volvo";
      myCars[2]="BMW";
  
      $.ajax({
          type: "POST",
          url: "WebService.asmx/Concat",
          data: {arr: myCars},        //can't figure out what to put here     
          success: onSuccess,
          Error: onError
      });
  });
  
  function onSuccess()
  {
      alert("testing");
  }
  
  function onError() 
  {
      alert("fail");
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help is appreciated!</p>