I am trying to call the following action method in a controller from a javascript function in a partial view:
[HttpPost]
public JsonResult RemoveNotifications(IList<Notification> notifications)
{
Context.Notifications.RemoveRange(notifications);
return new JsonResult();
}
This is the function that should call the server from the view:
function show(message) {
message += "</ul>"
document.getElementById('notifications').innerHTML = message;
$.ajax({
url: '@Url.Action("RemoveNotifications", "Notification")',
type: 'POST',
data: { 'notifications': "@Model.Notifications" },
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (data) {
}
});
}
The first part works fine, but the $.ajax part dosen't do anything. I also have the following added at the top of my view:
<script src="http://ift.tt/1bhFrtf" type="text/javascript"></script>
<script src="http://ift.tt/1bhFrth" type="text/javascript"></script>
<script src="http://ift.tt/1bhFrtj" type="text/javascript"></script>
Aucun commentaire:
Enregistrer un commentaire