I'm trying to get data based on what a user has selected in a drop down menu. I'm able to nab the selected value, but when I pass it to the controller in MVC 5, the data is null. Any ideas?
jQuery
LoadData($("#Dropdown").val());
function LoadData(selectedID) {
console.log(selectedID); //displays the right ID that was selected
$.ajax({
url: '@Url.Action("GetData")',
type: "GET",
dataType: "json",
contentType: 'application/json; charset=utf-8',
data: { selectedID: selectedID},
success: function (data) {...}
...
});
};
C#
public ActionResult GetData(string selectedID)
{
// Get data here
return Json(results, JsonRequestBehavior. AllowGet);
}