0
I have an AJAX function that is the event click
of a button where I pick up all the checkbox
which are checked and caught the values of each and play on an array this way:
$("#btnDropMessageSents").click(function (e) {
var ids = [];
$("#inbox-table input[type=checkbox]:checked").each(function () {
if (this.checked === true) {
ids.push($(this).val());
}
});
if (ids.length > 0)
{
$.ajax({
url: '/Inbox/DeleteDefinitive',
type: "POST",
contentType: "application/json; charset=utf-8",
data: values = [{ 'values': '1006' }, { 'values': '1005' }, { 'values': '1004' }],
dataType: "json",
traditional: true,
success: function (data, status, xhr) {
alert(data);
},
error: function (data) {
console.log(data);
}
});
}
})
On the line data: values
I put values in my hand to see if it would work anyway it was not.
Already mine ActionResult
in controller is like this:
[HttpPost]
public ActionResult DeleteDefinitive(string[] values)
{
var MensagemEnviadaDomain = new MensagemEnviada();
foreach (var item in values)
{
var Model = MensagemEnviadaDomain.GetItem(_ => _.COD_MENSAGEM == Convert.ToInt32(item));
MensagemEnviadaDomain.Edit(new MensagemEnviadaDto()
{
COD_MENSAGEM = Model.COD_MENSAGEM,
COD_AUTOR = Model.COD_AUTOR,
COD_REMETENTE = Model.COD_REMETENTE,
ID = Model.ID,
STATUS_AUTOR = Model.STATUS_AUTOR,
STATUS_REMETENTE = "E",
});
}
return (RedirectToAction("Sent", "Inbox"));
}
I have tried many times and different ways in my role in AJAX I do not know what can be but the mistake that gives is always the same :
Error 500 Internal Server Error
but this error is due to my array of values
empty arrives or as null
in action... How to fix this?
Hi, Rodrigo, please check to see if the title describes exactly the problem, saying "problem with X" could be the title of the 30 thousand questions of the site :) The ideal is to describe briefly and exactly what it is about. Formatting code with the Stack Snippets is only for HTML+CSS+JS that can be executed, otherwise use simple formatting: button
{ }
of the editor.– brasofilo