I have an action link which I want to do an HTTP Post to my Controller, however, I keep getting a HTTP 500.
Here is my jQuery
<script type="text/javascript">
$(document).ready(function () {
$('.thing').click(function (e) {
e.preventDefault();
$.ajax({
url: this.href,
dataType: "json",
type: "POST",
success: function (data) {
if (data.Success == true) {
// do something
}
else {
alert(data.Message);
}
},
error: function (textStatus, errorThrown) {
// request always errors
}
});
});
});
</script>
and my Action link code
@Html.ActionLink("my link", "DoStuff", "Dude", new { thingId = item.Id }, new { @class = "thing" })
My Controller
public class DudeController : Controller
{
[HttpPost]
public ActionResult DoStuff(int thingId)
{
return Json(new { Success = true, Message = string.Empty }, JsonRequestBehavior.AllowGet);
}
}
Any ideas?