我需要将值传递给Controller以制作PDF。 我创建了一个包含许多数据的Var Filter,以及其他各种必要的变量。
当我打电话给Controller时,没有任何事情发生。 我不是MVC和AJAX的专家。 有人能帮助我吗?
查看JavaScript:
function GeneratePdfUsuarios() {
var Filter = {
Nombre: $("#F_Nombre").val(),
Cargo: $("#F_Cargo").val(),
Iniciales: $("#F_Iniciales").val(),
UserName: $("#F_Usuario").val(),
Email: $("#F_Correo").val(),
Enabled: $("#EstadosList").val(),
BirthDay_Since: $("#F_Fecha_Desde").val(),
BirthDay_to: $("#F_Fecha_Hasta").val(),
RoleName: $("#RolesList").val(),
Sucursal: $("#SucursalesList").val()
};
var Title = "Usuarios";
var Description = "Listado de usuarios del sistema";
GeneratePdfList(1, Filter, Title, Description);
}
function GeneratePdfList(pDataCoType, pFilter, pTitle, pDescription) {
var token = $('[name=__RequestVerificationToken]').val();
var _data = {
DataCoType: pDataCoType //A number for Enumeration
, Filter: pFilter //An Object with Data
, Title : pTitle // Title for PDF
, Description: pDescription // Simple Description fpr Pdf
, __RequestVerificationToken: token
};
//ShowLoading();
$.ajax({
contentType: 'application/json; charset=utf-8'
,dataType: 'json',
url: "/Utility/GeneratePdfList",
type: 'POST',
data: _data,//JSON.stringify({ '_data': _data }),
success: function (data) {
if (data['success']) {
swal("Info","Entro","success");
//window.location.href = "@Url.Action("Usuarios", "Account")";
} else {
swal({
title: "Error!",
text: data['error'] + " !",
type: "warning",
timer: 100500,
allowOutsideClick: false,
allowEscapeKey: false,
showConfirmButton: true
});
swal("Peligro","Algo Fallo en el controlador "+e.Message,"warning");
//var message = document.createTextNode(data['error']);
//var p = $('#genericError')
//p.empty();
//p.append(message);
}
},
error: function () {
swal("Peligro", "Failed " + e.Message, "warning");
}
});
}
Controller中的ActionResult: