title: Passing parameters in a jQuery ajax call to an ASP.NET webmethod
body: <p>I know there are more threads about this but they dont help me and I'm going insane here!</p>
  
  <p>I wanna pass some parameters in to a web method using jQuery Ajax.</p>
  
  <pre><code>var paramList = '';
  for(i = 0; i &lt; IDList.length; i++){
      if (paramList.length &gt; 0) paramList += ',';  
          paramList += '"' + 'id' + '":"' + IDList[i].value + '"';  
      }
      paramList = '{' + paramList + '}';  
      var jsonParams = JSON.stringify(paramList);
  
  
      $.ajax({
          type: "POST",          
          url: "editactivity.aspx/UpdateSequenceNumber",          
          data: jsonParams,
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(response) {
  
          }
      });
  </code></pre>
  
  <p>In the ajax call, if I put data to paramList I get the error: "Invalid web service call, missing value for parameter: \u0027a\u0027."</p>
  
  <p>If I put data to jsonParams I get the error: </p>
  
  <blockquote>
    <p>"Cannot convert object of type \u0027System.String\u0027 to type
    \u0027System.Collections.Generic.IDictionary`2[System.String,System.Object]\u0027"</p>
  </blockquote>
  
  <p>If I write out <code>paramList</code>, it's in a correct JSON format like <code>{"id":"140", "id":"138"}</code></p>
  
  <p>If I write out <code>jsonParams</code>, it's in an incorrect format like <code>"{\"id\":\"140\",\"id\":\"138\"}"</code></p>
  
  <p>The web method: (it doesn't do that much yet..)  </p>
  
  <pre><code>[System.Web.Services.WebMethod]
      public static string UpdateSequenceNumber(string a, string b)
      {
           return a+b;
      }
  </code></pre>
  
  <p>What am I doing wrong? Can't seem to get this JSON thing right. </p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>After some help from the first answer I now send <code>{"id":["138","140"]}</code> in the AJAX request.</p>
  
  <p>The web method now takes a string called <code>id</code> as the parameter instead.</p>
  
  <pre><code>[System.Web.Services.WebMethod]
  public static string UpdateSequenceNumber(string id)
  {
       return id;
  }
  </code></pre>
  
  <p>Now I get the new error: </p>
  
  <blockquote>
    <p>"Type \u0027System.Array\u0027 is not supported for deserialization of
    an array."</p>
  </blockquote>