Reputation: 14897
How can I make an AJAX call to retrieve the URL of controller's action method?
Upvotes: 0
Views: 161
Reputation: 6747
Just inject the url into the javascript using the UrlHelper:
<script>
var url = '<%: Url.Action("ActionName") %>';
$.get(url);
</scrtip>
Upvotes: 1
Reputation: 10540
if you write the JS in your view you can write something like this.
var ajaxUrl = <%= Url.Action("NameOfAction") %>
this will put the url into your javascript code.
Upvotes: 2