codeigniter csrf protection with ajax

Posted by Yarandi on Stack Overflow See other posts from Stack Overflow or by Yarandi
Published on 2012-04-07T15:34:54Z Indexed on 2012/04/08 5:29 UTC
Read the original article Hit count: 264

i have a small problem here which i cannot fix,This post goes through but the response returns a “500 internal server error”

who to fix it?

JS in view:

    function load(value)
{
  var utype = value;
   if(utype>0)
  {
      new Ajax.Request('<?php echo base_url().'another/load';?>'+'/'+utype,
      {
        method:'post',
        onSuccess: function(transport){
          var response = transport.responseText || "no response text";
          if(response!="no response text")

          document.getElementById('prog_id').innerHTML = response;
        },
        onFailure: function(){ alert('Something went wrong ...') }
      });
      }

error in firebug :

An Error Was Encountered

The action you have requested is not allowed.

when i change CSRF protection to False in config file its work for me.but i want protect this request with CSRF enabled.

after search in CI forum i found this this link codeigniter-csrf-protection-with-ajax but i cant solve by it.can any one help me?

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about codeigniter-2