I'm trying to send a value from my controller to an input. I tried with the following code and it does not work, any suggestions?
I'm sending you to call from an onclick.
This is my code:
public ActionResult Suma()
{
decimal suma;
suma = (decimal)Session["Suma"];
return View(suma);
}
function Sumar() {
$("#sub").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("Suma","prueba")',
datatype: 'json',
success: function (suma) {
$('#sub').val(suma);
},
});