Codeigniter ajax CSRF problem
You might like to try this code I’ve used. It works great: <script type=”text/javascript”> $(function(){ $(‘.answerlist’).each(function(e){ $(this).click(function(){ var valrad = $(“input[@name=answer]:checked”).val(); var post_data = { ‘ansid’: valrad, ‘<?php echo $this->security->get_csrf_token_name(); ?>’ : ‘<?php echo $this->security->get_csrf_hash(); ?>’ }; $.ajax({ type: “POST”, url: “<?php echo base_url(); ?>online/checkanswer”, data: post_data, success: function(msg){ /// do something } }); }); … Read more