views:

30

answers:

2

Hi,

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  A: 

You missed the leading slash:

 $.post("/User/Delete/1");
Khnle
You are right...post worked fine, just didnt see the result:)
Peti
+1  A: 

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");
    });
});
ckramer