Jquery Ajax MVC controller URL issue

asp.net-mvc, c#, jquery, routes

Solution

$.ajax({
    url: "@Url.Action("ViewDetails", "ControllerA")", 
    type: "GET", 
    dataType: "html",

and

$.ajax({
    url: "@Url.Action("Search", "ControllerB")", 
    type: "GET", 
    dataType: "html",

This way you're using the route table and not generating urls willy nilly

Problem

I have a jquery code which opens a dialog. This dialog is a partial view which renders from the response of a jquery Ajax call "`http://test.com/ControllerA/ViewDetails`". Ajax call code looks like below ``` $.ajax({ url: "ViewDetails", type: "GET", dataType: "html", ``` The dialog box has button which has to make another Jquery Ajax call (this has go against a different controller and action). Ajax code looks like below. ``` $.ajax({ url: "ControllerB/Search", type: "GET", dataType: "html", ``` The above ajax call fails to find search action because The URL will get changed to `http://test.com/ContollerA/ControllerB/Search`. I feel this is something related to a route config. But i need some directions from you all.

Original source