title: Pass Data string using ajax to controller method
body: <p>I am creating a filter list. I have a several multi-select lists where the user can choose several options. The problem is I am using ajax to return the values and call a controller method which will return a Json data which will then be displayed on the website. But the problem is it doesn't work. </p>
  
  <p>Controller Method:</p>
  
  <pre><code>[HttpPost]
  public ActionResult FilterData(string a, string b, string c, string d){
    //Do Something with the strings e.g. filter the data.
    return Json(result, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>Ajax Method for getting filtered data: </p>
  
  <pre><code>$(document).ready(function() {
  $("#submitBTN").click(function() {
  var ab = $('#selectedID1').val();
  var bc = $('#selectedID2').val();
  var cd = $('#selectedID3').val();
  var de = $('#selectedID4').val();
  
  $.ajax({
         contentType: "application/json; charset=utf-8",
         url:"/Controller/FilterData",
         type: "POST",
         data: JSON.stringify({a: ab, b: bc, c: cd, d:de }),
         success: function(result){
  
         } 
         error: function(){}
       });
         return false;
        });
     });
  </code></pre>
  
  <p>Using firebug I can see the right values are posted. And I know that if I manually select string a via the url link it get the correct filtered data. However, this data does not seem to get into the method and output all the data without being filtered using the postes values.</p>
  
  <p>The problem is that the Data Posted is not being pciked up or sent to the method FilterData, so it returns all the data as it should do if there are no filter options selected. I would like to know how I can fix the code so I can get the data posted by ajax to send that data to method FilterData parameters e.g. string a, string b, string c and string d. </p>