again problem with ajax RRS feed

  • Question

  • User-1062853889 posted

    Hello, againg I have problem with ajax, the data is null.


     var data = { "name": "panchito" };
                    url: '/ajax/GuardarUser',
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(data),
                    success: function (data) {
                    error: function (err) {
                        alert("Error: " + err.responseText);


            public IActionResult GuardarUser([FromBody]string name)
                var data = name;
                data = data + "ooo";
                var data1 = name;
                return Json(data1);

    the name is null

    If remove this line contentType: 'application/json', there show me this error 415
    If I put this line contentType: "application/json; charset=utf-8" the result is null, the name = null

    Some idea?

    Thursday, May 20, 2021 8:26 PM

All replies

  • User-1062853889 posted

    ok, is working.
    I fix romove this lines

    dataType: 'json',
                    contentType: 'application/json',

    Thursday, May 20, 2021 8:52 PM