Reputation: 375
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.
Upvotes: 2
Views: 5484
Reputation: 155
The best way is to use
url: '../ControllerA/ViewDetails'
it worked for me when the culture is in url
Upvotes: 1
Reputation: 63522
$.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
Upvotes: 6