Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 3 - 403 Forbidden on POST from jQuery.ajax() asynchronous request
#2

(This post was last modified: 04-19-2021, 06:46 AM by kleber.)

I generally use ajaxPrefilter(https://api.jquery.com/jquery.ajaxPrefilter/) in my projects:

Code:
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {

        if (options.type.toLowerCase() === "post" && options.processData != false) {

            // initialize `data` to empty string if it does not exist
            options.data = options.data || "";

            // add leading ampersand if `data` is non-empty
            options.data += options.data ? "&" : "";

            // add _token entry
            options.data += csrf_name + "=" + csrf;
        }

I just need to define the values csrf_name, csrf in the header for example, that all requests from my system are sent with this security token.
Reply


Messages In This Thread
RE: CodeIgniter 3 - 403 Forbidden on POST from jQuery.ajax() asynchronous request - by kleber - 04-19-2021, 06:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB