0

I want to make a POST request to my Controller with jquery.

function Send() {
   $.post("User/Delete/1");
}

<a href="#" onclick="Send()">Delete</a>

It doesn't work, however if i write this code:

<%= Html.ActionLink("Delete", "Delete", new { onclick = "$.post('User/Delete/1')" })%>

it works fine. Unfortunetly i cant use this phrase because i need to call that Send() method from a jQUERY UI dialog too.

Thank you

2 Answers 2

2

You missed the leading slash:

 $.post("/User/Delete/1");
Sign up to request clarification or add additional context in comments.

1 Comment

You are right...post worked fine, just didnt see the result:)
1

You may have better luck binding to the Click event using jQuery, which would require you to be able to identify your link. So lets say you give it an id of postLink, then you could do something like:

$(document).ready(function() {
    $("#postLink").click(function() {
        $.post("User/Delete/1");
    });
});

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.