js code to define an ajax call:
function InitDataServices()
{
amplify.request.decoders.myDecoder =
function (data, status, xhr, success, error)
{
if (status === "success") {
success(data);
} else if (status === "fail" || status === "error") {
error(message, status);
} else {
error(message, "fatal");
}
};
amplify.request.define("Emision_FiltrarSeguros", "ajax", {
url: "http://localhost:63721/api/emision/filtrar",
type: "POST",
dataType: "json",
decoder: "myDecoder"
});
}
Then the code to make the actual ajax call is:
function Emision_FiltrarSeguros(requestData,okFunction, failFunction)
{
amplify.request({
resourceId: "Emision_FiltrarSeguros",
contentType: "application/json",
data: JSON.stringify(requestData),
success: function (data) {
okFunction(data);
},
error: function (message, level) {
failFunction(message,level);
}
});
};
And finally this code in the page to make the call:
function FiltrarSeguros()
{
this.request = {Ramo:-1,
NroSocio: 107701,
NroSeguro:-1,
NroEndoso:-1,
Vigentes:0,
Patente:"" };
Emision_FiltrarSeguros(request,okFiltrarSeguros, failFiltrarSeguros);
}
The controller code is this:
public List<FiltroSeguroResponse> Filtrar(FiltroSeguroRequest request)
{
return DLL.Service.EmisionService.FiltrarSeguros(request, "jdh");
}
The problem is that the data that i POST from the page never get mapped to the request (of type FiltroSeguroRequest, whose properties are the same as the object literal I build in the ajax call) parameter. What is wrong??? Thanks.