ASP.NET MVC Pass mutiple params from getJson to controller

Posted by andyJ on Stack Overflow See other posts from Stack Overflow or by andyJ
Published on 2009-03-30T19:46:46Z Indexed on 2010/04/07 4:03 UTC
Read the original article Hit count: 834

Filed under:
|
|
|

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 = "" });

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc