403 error with ajax on CodeIgniter

403 forbidden codeigniter
codeigniter csrf ajax problem
csrf regenerate codeigniter ajax
403 forbidden ajax post php
the action you have requested is not allowed. in codeigniter ajax
failed to load resource: the server responded with a status of 403 forbidden ajax
how to solve 403 forbidden error in codeigniter
403 forbidden error in ajax post call

I want to use Ajax (with the JQuery plugin Datatables) on my CodeIgniter application and when I put the address of the controller, I have a 403 error. I use the 3.1.8 version of Codeigniter. My code :

$('#Table').DataTable( {
    "processing": true,
    "serverSide": true,
    ajax: {
        url: '<?= base_url('myController/data');?>',
        "type": "POST"
    },
    "columns": [
        { "data": "col1" },
        { "data": "col2" },
        { "data": "col3" },
    ]
} );

I tried to put the $config['csrf_regenerate'] at false but nothing change

Your Url shoud look like :

url: "<?= base_url('myController/data');?>",

Ajax request with codeigniter 403 (forbidden), Add this code in your footer view before including JS file <?php $CI =& get_instance(); ?> <script> var csrf_name = '<?php echo  I have a codeingiter 3 app which uses the grocery crud library. However,I came across an issue.No ajax-based front-end actions work.The search functionality for example does not work.When i open my

"url": base_url + 'myController/data',

try this as your url, echo in myController to see if you are going to the url or not.

I hope you've permission to access that path.

Ajax 403 error, This is Jquery code : Code: <script> $( document ).ready(function() { var stato=$("​#id_class_stato_agenda_id option:selected").val(); I'm trying to set up routing to a page on my site with Codeigniter, but I just get a 403. I can't understand why. 403 forbidden with URI routing in Codeigniter

You need a csrf token as well to be passed with your ajax data. Without it you'll get 403 error. Since, $config['csrf_regenerate'] is false in your config, you only need to get the token value once, and use it in all your requests.

Use the below functions to get the token name and get a value for it.

$this->security->get_csrf_token_name();
$this->security->get_csrf_hash();

In your controller method, you set the values of $data['csrf_token_name'] and $data['csrf_token_hash'] using the above methods to be used in the view code below.

$('#Table').DataTable( {
    "processing": true,
    "serverSide": true,
    ajax: {
        url: '<?= site_url('myController/data');?>',
        "type": "POST",
        data: { '<?php echo $csrf_token_name; ?>' : '<?php echo $csrf_token_hash; ?>' }
    },
    "columns": [
        { "data": "col1" },
        { "data": "col2" },
        { "data": "col3" },
    ]
} );

403 error in AJAX to Controller, The only thing someone could point out is that a 403 is "access forbidden", if that helps. View->textbox.php. Code: <div style="text-align:center;"> i dont know why we are complicating so much, is the content of your variables pure html? you could just replace all double quotes with single quotes before sending the data to codeigniter. I understand your point that it should be the same, but somewhere in the codeigniter code someone forgot to prevent code injection, and i think that is off

AJAX request returns a 403 error, 09-20-2013, 06:45 AM. [eluser]Fyodor[/eluser] Hello I am receiving 403 error when I am trying to request Php function from model through AJAX: Ajax is: Code:​. I am displaying the first name in my textbox autocomplete using ajax but my ajax URL is not working. It's every time showing in the network tab . 403 Forbidden. I tried ajax URL like this

ajax Forbidden error, and in view in ajax post requests I send parameters from this security object. It works in 1 case and retiurns 403(Forbidden) error in 2 cases: How to send AJAX request in CodeIgniter If you know how to send jQuery AJAX request in Core PHP then it is simpler for you to do it in CodeIgniter. In CodeIgniter, you can use the controller and model to handle AJAX call instead of creating a separate file.

How to solve CSRF 403 Error during AJAX Request in CodeIgniter 3 , In first AJAX request, we receive success response, - From second to rest request we receive Duration: 7:55 Posted: Jun 8, 2018

Comments
  • It should be '<?= base_url('myController/data');?>', - you're missing single quotes on your base url parameter.
  • Sorry I forgot it but notinh change, I have the error
  • try site_url() in place of base_url()
  • And there is no security problem even if the $config['csrf_regenerate'] is false ? Have I to put "$this->security->get_csrf_token_name(); $this->security->get_csrf_hash();" in my view ?