Send value from actionResult to input

1

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);

        },
    });
    
asked by Cesia Cruz Monarrez 15.03.2018 в 23:10
source

1 answer

1

I think it should be:

    public JsonResult Suma() {
        decimal suma;
        suma = (decimal)Session["Suma"];

        return Json(suma);
 }
    
answered by 16.03.2018 / 08:38
source