title: How to pass multiple arguments using JQuery.Ajax in ASP.NET MVC
body: <p>Hi guys i'm new to JSon and not too sure how do i pass the data around. I am using ASP.NET MVC as my development platform.</p>
  
  <p><strong>In The View:</strong></p>
  
  <pre><code> $(document).ready(function() {
      $("select#Colors").change(function() {
         var photoCategory = $("#Colors &gt; option:selected").attr("value"); // 1st parameter
         var userID = $(".userID").attr("value"); // 2nd parameter         
         $.ajax({
              type: "GET",
              contentType: "application/json; charset=utf-8",
              url: "/FindPhotos/" + photoCategory ,
              data: "{}",
              dataType: "json",
  
              success: function(data) {
              $('#ProductsDiv &gt; div').remove(); 
                  if (data.length &gt; 0) {
                      var options = ''; 
                  } .......
         });
      });
  });
  </code></pre>
  
  <p><strong>In Global.asax:</strong></p>
  
  <pre><code>routes.MapRoute(
         "FindPhotos",
         "FindPhotos/{category}",
          new { controller = "Clinical", action = "FindPhotosByCategory", category = "" }
         );
  </code></pre>
  
  <p>So everything works fine this way since i'm only passing one parameter, 'photoCategory', in the $.ajax url. My goal here now is to pass a 2nd parameter, which is the userID, so i can use them both in the controller method below. </p>
  
  <p><strong>In The Controller:</strong></p>
  
  <pre><code> public JsonResult FindPhotosByCategory(string category, string userID) {
  
          List&lt;PhotoSet&gt; photoset = Repository.GetPhotoSetByUserID(userID);
  
          return new JsonResult
          {
               Data = (from p in photoset 
                       where p.PhotoCategory == category
                       select p).ToArray&lt;PhotoSet&gt;()
          };
      }
  </code></pre>
  
  <p>Does anyone know how to write the $.ajax() method so i can pass in the 2 parameters to the controller? thanks!</p>