Antonio MC
Antonio MC

Reputation: 21

Issue with ajax and toastr.js

I'm using toast.js in an Asp.Net Core 2.0 application. Right now I have a problem with an ajax call. It seems that all works fine but my ajax doesn't execute success or error function.

The request finish with status 200 in chrome and the response actually show me the data that I return from my method.

The thing that I don't know why happens is that Chrome say that the Initiator is toastr.js instead of my function.

This is just an example of my function in javascript

function callAjax() {
var row = "1";
var json = "{'TwitterId':'" + row + "'}";

var token = $('input[name="__RequestVerificationToken"]').val();
var headers = {};
$.ajax({
    type: 'POST',
    url: "/Accesos/Index?handler=Example",
    contentType: 'application/json',
    async: false,
    beforeSend: function (xhr) {
            xhr.setRequestHeader("XSRF-TOKEN",
                $('input:hidden[name="__RequestVerificationToken"]').val());
        },
    data: JSON.stringify({
        Test: 'test'
    }),
    dataType: "json",
    success: function () {
        alert("It's works");
    },
    error: function (xhr) {
        alert("There is a problem");
    }
});

}

And this is the method in codebehind

    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<JsonResult> OnPostExample(string Test)
    {
        var respuesta = new List<string> { "1", "string1", "string2" };
        return new JsonResult(true);
    }

This is the result that shows the debug in Chrome

Upvotes: 1

Views: 460

Answers (1)

Antonio MC
Antonio MC

Reputation: 21

This issue was solved in NToastNotify version 5.0.0

Upvotes: 1

Related Questions