Sent some table of inputs with the following code:
$('#guardar').click(function(){
var header = $('table thead tr th').map(function () {
return $(this).text().trim();
});
var Datos = $('table tbody tr').map(function (i) {
var row = {};
$(this).find('td').each(function (i) {
var rowName = header[i];
row[rowName] = $(this).find('input').val();
});
return row;
}).get();
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: "POST",
url: '@Url.Action("Guardar", "Inicio")',
data: JSON.stringify({Datos}),
dataType: JSON,
success: function (data) {
},
error: function (r) {
alert("Error del servidor");
}
});
});
and I receive it with the controller:
public JsonResult Guardar(List<Temp> Datos)
{
object ver = Datos;
return Json(Datos, JsonRequestBehavior.AllowGet);
}
and I have the class:
public class Temp
{
public String Albaran;
public String Cp;
public String Destinatario;
public String Direccion;
public String Fecha;
public String Observaciones;
public String Poblacion;
public String Provincia;
public String Telefono;
}
Capture the json in the console.log:
The fact is that I receive all 20 rows in the jsonresult that I have but all their values in null.
Sold
I have to add {get; set} to the variables of the Temp class