0

I have the following in my MVC View:

    <a href='@Url.Action("EmailPerson", "SupportNeeded")'> Email </a>

Below, SupportNeeded is the Controller and EmailPerson in the method

What is the equivalent if I do it in Jquery. Obviously I do not need the Email Lable. I just want it to automatically go to EmailPerson Method in SupportNeeded controller.

Note that I have EmailPerson and EmailPerson with HttpPost in my controller.

I tried in my Jquery

    '@Url.Action("EmailPerson", "SupportNeeded")'

but that didn't do anything for me. I also tried the .post :

    var url = '@Url.Action("EmailPerson", "SupportNeeded")';
    $.post(url), function (data) { });

but it went to the Method that has [HttpPost]. I need it to go to the method that does not have [HttpPost]. I then tried .get but did not do anything for me.

2 Answers 2

1

You should be able to accomplish this by using regular JavaScript.

window.location = '@Url.Action("EmailPerson", "SupportNeeded")';
Sign up to request clarification or add additional context in comments.

Comments

0

It's unclear what exactly you need. If you want to use $.get which will perform an ajax request, this works:

$.get("@Url.Action("EmailPerson", "SupportNeeded")");

If you're trying to redirect to that action you can do:

window.location.href = "@Url.Action("EmailPerson", "SupportNeeded")";

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.