ajax - MVC action method not getting hit -


i have layout page left navigation bar defined. want load sub options menu item in left navigation bar. have added ajax click event top menu item . hit default method defined in routemap, not action method have written load partial view.

my routeconfig.cs file. have other maps defined file. method getting hit.

routes.maproute(            name: "default",            url: "{controller}/{action}/{id}",            defaults: new {                 controller = "client",                 action = "index",                 id = urlparameter.optional }         ); 

the menu item in _layout page

 <li>     <a href="#" id="recentlist">recent list</a>         <ul>             <li>                <a href="#" class="back">main menu</a>             </li>             <div id="recentclients"></div>          </ul>  </li> 

this javascript defined in _layout page.

$('#recentlist').click(function () {                    $.ajax({             url: "@url.action("recentlist", "navigation")",                          success: function (r) {                 $('#recentclients').html(r);             }         });     }); 

but never hits recentlist method in navigationcontroller. goes default method defined in routeconfig.cs

also controller code.

public actionresult recentlist()     {         var clientmodel = new clientmodel();         var recentllist = clientmodel.getrecentlist();         return partialview("_recentllist", recentllist );     } 

hard 100% sure, you're actionresult named recentlyusedlist while your're trying hit endpoint called recentlist in navigationcontroller.

so should be:

@url.action("recentlyusedlist", "navigation"); 

and controller needs named navigationcontroller.


Comments