Personally I did not handle anything in jquery / ajax and wanted to pass a parameter to the controller.
I have a modal that opens only to ask if the person is aware of the cancellation where the only field that needs to pass is a hidden with the id of what is going to be deleted.
I would like to know how to stay my controller. I'm using asp net mvc 5.
<script>
$(function () {
jQuery('button.delete').on('click', function () {
var $row = jQuery(this).closest('tr');
var $columns = $row.find('td');
$("#nrotitulo").val($row.find('td:eq(1)').text());
$("#razao").val($row.find('td:eq(2)').text());
$("#cnpjtitulo").val($row.find('td:eq(3)').text());
$("#valortitulo").val($row.find('td:eq(7)').text());
$row.find('td:eq(8)').text()
$row.find('td:eq(9)').text()
var obj = {
titulonro : $("#nrotitulo").val($row.find('td:eq(1)').text()),
razaosocial : $("#razao").val($row.find('td:eq(2)').text()),
titulocnpj : $("#cnpjtitulo").val($row.find('td:eq(3)').text()),
titulovalor : $("#valortitulo").val($row.find('td:eq(7)').text()),
systicketID : $row.find('td:eq(8)').text(),
aditiveID : $row.find('td:eq(9)').text()
};
var parametros = JSON.stringify(obj);
alert('error');
});
$("#btn-delete").click(function () {
alert('ok');
$.ajax({
type: 'POST',
url: '/Cliente/TicketDelete',
contentType: "application/json; charset=utf-8",
data: parametros,
dataType: "json",
success: function (parametros) {
}
});
});
});
</script>