[Solved] jquery ajax have error [closed]


The error would probably be from this being a plain Object rather than the Element.

Every function has its own this value, determined when it’s invoked. And, inside of the success callback, this will typically refer to the settings of the request.

$.ajax({
    // ...
    success: function () {
        console.log(this.type, this.url); // "POST" "/funfact_ajax"
    }
});

jQuery.ajax() includes a context option to specify a different value to use, so it can refer to the Element there as well:

$.ajax({
    // ...
    context: this,
    success: function () {
        $(this).text(eval(send.ff_k)+1);
    }
});

1

solved jquery ajax have error [closed]