I'm trying to call a MVC Controller action with AJAX passing some parameters.
I have done this sometimes in this application and it works fine.
I have no idea why only THIS ONE doesn't work.
function excluirDetalhe(button, tab) {
var index = $(button).closest('tr').index();
var myTable = document.getElementById(tab);
var id = myTable.rows[index].cells[0].innerHTML.trim();
$('#' + tab + ' tr:eq(' + index + ')').remove();
$.ajax({
traditional: true,
url: "entidades/gravaCookie",
type: 'post',
data: { id: id, detalhe: "E" },
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
This is my controller method:
public void gravaCookie(string id, string detalhe)
{
string key = "een_id";
if (detalhe.Equals("E"))
key = "een_id";
if (detalhe.Equals("C"))
key = "eco_id";
if (detalhe.Equals("B"))
key = "eba_id";
cookie.Values.Add(key, id);
}
Just a reminder that I'm doing exactly I did in other Ajax calls, but only this one in particular is not working.
Does anyone have any idea?