Welcome Guest, Not a member yet? Register   Sign In
CSRF giving problem with ajax
#7

when you send custom fields by ajax, then CSRF token is not send in request data so you should post the CSRF token to your data option in AJAX request data..

PHP Code:
$.post(url, {'<?php echo $this->security->get_csrf_token_name(); ?>':'<?php echo $this->security->get_csrf_hash(); ?>'other_fields"bla"}, function(data){
 
  //code here
}) 

when you posting form data by ajax, then CSRF library automatic append hidden token element in form, so form works well Shy
Passionate PHP Programmer & Codeigniter Developer :- Always happy to help you!
Reply


Messages In This Thread
CSRF giving problem with ajax - by tancredolt - 05-02-2015, 09:52 PM
RE: CSRF giving problem with ajax - by prabhakar - 05-03-2015, 06:25 AM
RE: CSRF giving problem with ajax - by PaulD - 05-04-2015, 09:06 AM
RE: CSRF giving problem with ajax - by matbeard - 05-06-2015, 07:20 AM
RE: CSRF giving problem with ajax - by tancredolt - 05-29-2015, 12:45 AM
RE: CSRF giving problem with ajax - by techbat - 05-29-2015, 05:56 AM
RE: CSRF giving problem with ajax - by kintech - 09-30-2019, 05:16 AM
RE: CSRF giving problem with ajax - by albertleao - 09-30-2019, 08:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB