jQUERY onclick post

jQUERY onclick post

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

Problem with Primary Key in a Partial View shared by Create and Edit views


How to start a new ASP.NET MVC site?
You missed the leading slash:.
How can I determine the current controller action in an mvc sitemap?

Check ASP.NET MVC values (roles) from client (jQuery)

Building a repeatable HTTP request parameter


“ASP.NET Webforms MVP” as an alternative to “ASP.NET MVC” [closed]
You may have better luck binding to the Click event using jQuery, which would require you to be able to identify your link.

Asp.net Mvc Routing problem
So lets say you give it an id of postLink, then you could do something like:.
How to dynamically determine which HTML 'wrapper' file to use based on the Action Method being executed?
$(document).ready(function() {     $("#postLink").click(function() {         $.post("User/Delete/1");     }); }); 

53 out of 100 based on 18 user ratings 43 reviews