Last post Aug 20, 2009 06:06 PM by maverickhyd
Aug 20, 2009 11:51 AM|coosha|LINK
I have wrong URL in my ajax calls.
url: "Home/GetDetails", ......});
HomeController has action GetDetails().
All works fine, when I load page with URL http://localhost/projectName. Ajax URL is http://localhost/projectName/Home/GetDetails
But after loading http://localhost/projectName/Home/Index all my ajax calls are going to http://localhost/projectName/Home/Home/GetDetails and thats wrong.
Please, how can I solve this?
Ajax and MVC
Aug 20, 2009 01:29 PM|leather|LINK
This looks to me like a Jquery issue but anyhow... you need to use the Url object to generate a relative Url. In the preview this had problems in that it didn't pick up the ajax context, but it does now.
One way would be to put something like this into you script:
var myUrl = '<%= Url.Action("GetDetails","Home"); %>';
url: myUrl });
Aug 20, 2009 06:06 PM|maverickhyd|LINK
You can Pass URL as
url:"/Home/GetDetails"(with Slash before Home)
or you can send by using url.Action as mentioned in above Post
var urlAction = "<%= Url.Action("GetDetails", "Home") %>";