title: Sending a javascript array to code behind(c#) using ajax
body: <p>I'm a bit new to C# and javascript so while my question is specific I am open to any alternatives.</p>
  
  <p>I have an array of values (that I have created in a javascript function) that I want to send to my code-behind file to be used in a method. From what I've researched using ajax and stringifying the array with JSON seems like the best method.</p>
  
  <p>My questions are</p>
  
  <ol>
  <li><p>Can I pass the array using this method?</p></li>
  <li><p>How do I capture the information on the server side(in my code-behind?)</p></li>
  </ol>
  
  <p>Javascript passing the values</p>
  
  <pre><code>var jsonvalues = JSON.stringify(values);
  var callback = window.location.href
  $.ajax({
    url: callback
    type: "POST",
    contentType: 'application/json',
    data: jsonvalues
  });
  </code></pre>
  
  <p>I've seen many solutions using [WebMethod] or some kind of WebService to capture the data, can I use this to do work in my code-behind file without having to return data?</p>
  
  <p>Here is what I'm using on my code-behind file</p>
  
  <pre><code>[WebMethod]
  public static void done(string[] ids)
  {
  String[] a = ids;
  }
  </code></pre>