title: Passing multiple parameters in Ajax Call with Razor
body: <p>So essentially, I'm building a web API, and I'm trying to use ajax to query a web service that accepts two arguments. I need to pass a List of Stings (SSNs) and I need to pass a single string to determine which environment it queries. ("a" for acceptance, and "i" for integration). </p>
  
  <p>I'm using cshtml with razor. And so far this section is successfully giving me what I want from the divs. </p>
  
  <pre><code>var pInputSssns  = document.GetElementById(“SSNinput”).value;
  var pTestRegion = document.GetElementById(“testRegion’).value;
  </code></pre>
  
  <p>However, just beneath it. I'm trying to insert both these params into an ajax call. </p>
  
  <pre><code> $.ajax({
          type: 'GET',
          contentType: "application/json; charset=utf-8" 
          url: "myurl",
          data:"{}",
          success: function (data) {
              // populate a table
          }
      });
  </code></pre>
  
  <p>I've heard multiple opinions on how that can be done. Can I serialize them both as JSON, and then put two JSON objects in the data parameter? I've also heard that I can pass a c-sharp object, but if I try and do that I can't access the html variable while I'm inside the Razor code. </p>
  
  <pre><code> @{ AjaxParam ap = new AjaxParam(); ap.pInputSsns = pInputSsns;}
  </code></pre>
  
  <p>Is there a good way to pass both of them in there? For reference, here's the Controller: </p>
  
  <pre><code>[ScriptMethod (ResponseFormat = Response Format.Json)] 
  [System.Web.Http.HttpGet]
  public JArray GetSSNAssociations([FromUri] List &lt;string&gt; pInputSsns, string pTestRegion)
  {
  \\ do something
  }
  </code></pre>
  
  <p>Appreciate it everyone. </p>