0

How can I make an AJAX call to retrieve the URL of controller's action method?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Just inject the url into the javascript using the UrlHelper:

<script>

var url = '<%: Url.Action("ActionName") %>';

$.get(url);

</scrtip>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.