I am facing an issue where I am unable to receive the data sent with AJAX jQuery to a .NET server as a parameter, modify it in memory, and then convert it to JSON. Any assistance in resolving this problem would be greatly appreciated.
JAVASCRIPT
document.querySelector('input#btnGuardar').onclick = function (e) {
e.preventDefault();
var data = $('form#form_boleta').serializeJSON();
$.ajax({
type: "post",
url: "/Comprobante/Factura",
data: data,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (result) {
if (result === "success") {
swal({
title: "¿Generar Otro Comprobante?",
text: "¡El comprobante se ha generado de manera correcta!",
type: "success",
showCancelButton: true,
confirmButtonClass: 'btn-success',
confirmButtonText: 'Si',
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
self.parent.location.reload();
} else {
window.location.href = "/Plataforma/Dashboard";
}
});
}
else {
var mensaje_error = document.getElementById('MensajeError');
//$("#MensajeError").fadeTo(1000, 1);
//$("#MensajeError").fadeOut(5000);
//return false;
}
}
})
};
CONTROLLER MVC .NET
public JsonResult Factura(string[] json)//The json parameter appears as Null
{
string result;
if (json != null)
{
//Modify the data received json.
result = "success";
}
else
{
result = "error";
}
return Json(result, JsonRequestBehavior.AllowGet);
}