This is a migrated thread and some comments may be shown as answers.

ASP Net core ajax not recognizing passed data.

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kamlesh Singh Bisht
Top achievements
Rank 2
Kamlesh Singh Bisht asked on 25 Jun 2019, 12:09 PM

I have controller method which looks like this:

[HttpPost]
public IActionResult CreateNew(string Naslov, int KorisnikID, int GrupaID, string Tekst)
{
    //Some code
}

 

Ajax function that is calling this is:

$.ajax({
    type: "POST",
    url: "/Story/CreateNew",
    contentType: "application.json; charset=utf-8",
    dataType: "json",
    data: JSON.stringify({
        "Naslov": $("#Naslov").val(),
        "KorisnikID": @Context.Request.Cookies["kid"],
        "GrupaID": $("#GrupaID").val(),
        "Tekst": $("#Tekst .ql-editor").html()
    }),
    success: function (message) {
        var elements = message.split("-");
 
        if (elements[0] == "success") {
            window.location.href = '/Clanak?ID' + elements[1];
        }
        else {
            alert(message);
        }
    },
    error: function (xhr, status, error) {
        alert(xhr + " " + status + " " + error);
    }
});

 

Method is entered but all parameters are null.

Also when i change it to GET it works (but i need post since i have problem with length of string)

 


1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 25 Jun 2019, 01:10 PM
Hi Kamlesh,

It looks like you have posted your question in the forum dedicated for Telerik UI for ASP.NET AJAX.

Please post your ASP.NET Core related questions at the Telerik UI for ASP.NET Core forum at:

https://www.telerik.com/forums/aspnet-core-ui.

Thank you!

Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Kamlesh Singh Bisht
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Share this question
or