Hi,
Are you using submit button , type = submit or type = button.
type = button
may solve it
Regards.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
I am developing an Asp.net Core Mvc application in which I need to send , as usual, some data from an ajax call to an MVC action.
The ajax code is as follows :
**function ShowHideAttivita(model, idriga) {
var dati =model;
var idcommessa = $('#IdselectCommessa' + idriga + ' option:selected').val();
$.ajax({
url: 'cambiaCommessa',
type: 'POST',
dataType: "html",
contentType: "application/json",
data: dati,
success: function (result) {
$('#IdrigaSezioneCommessa' + idriga).replaceWith(result);
}, error: function (error) {
var x = error.responseText;
VisualizzaMessaggio('errore', 'E', '');
}
});
}**
The corresponding MVC Controller Action which is listening is as follows ;
**[HttpPost]
public async Task<ActionResult> cambiaCommessa( RapGiornalieroExtended dati)
{
try
{
DettaglioPresenze DP = new DettaglioPresenze();
return PartialView("~/Views/Home/_rigaCommessa.cshtml", DP);
}
catch (Exception ex)
{
throw ex;
}
}**
It seems I can call the action correctly, but the content in the data sent is null (the fields of the "dati" parameters).No matter how I change the code in the sending Ajax, when I break into the Action , the best result I can get is getting a "dati" parameter (which is a complex type itself) with all its fields null, in spite of the fact that, in the sending ajax, i verified the content is not null.
Most inquietingly, another application from which this same bunch of code is taken works perfectly , and there are no differences in the Ajax, in the Controller, in the Action, and in the data content itself, between the two situations.
Any suggestions ?
Thanks
Hi,
Are you using submit button , type = submit or type = button.
type = button
may solve it
Regards.