ASP.NET MVC Pass mutiple params from getJson to controller
- by andyJ
Hi,
I am making a call to a controller action in javascript using the getJson method. I need to pass two parameters to my action method on the controller, but I am struggling to do so. I do not fully understand the routing tables and not sure if this is what I need to use to get this working. Please see example below of what I am trying to do.
var action = "<%=Url.Content('~/Postcode/GetAddressResults/')%>" + $get("Premise").value + "/" + $get("SearchPostcode").value
$.getJSON(action, null, function(data) {
$("#AddressDropDown").fillSelect(data);
});
This is my route which I don't understand how to make use of...
routes.MapRoute(
"postcode",
"Postcode/GetAddressResults/{premise}/{postcode}",
new { controller = "Motor", action = "GetAddressResults", premise = "", postcode = "" });