Welcome Guest, Not a member yet? Register   Sign In
CSRF with Jquery (Jeditable)
#1

[eluser]wakey[/eluser]
Hi,

I'm using the CSRF plugin as found here - http://ellislab.com/forums/viewthread/92399/

It is working correctly across my site, but I use ajax in a few places with the Jeditable inline editor. I need to add the hidden ci_token to my jeditable fields but I am not sure how to go about it.

Has anyone experience with problems like this?

My jeditable code is as follows -

Code:
$(function() {
        
  $(".target3ac_editable").editable('<?=base_url()?>dashboard/save-t3ac', {
      indicator : "<img src='&lt;?=base_url()?&gt;images/indicator.gif'>",
      type   : 'textarea',
      id  : 'target3achieve_id',
      name: 'target3_achieve',
      select : true,
      submit : 'OK',
      cancel : 'cancel',
      cssclass : "editable",
      data: function(value, settings, ) {

           return retval;
      }

  });

});

Thanks Smile
#2

[eluser]wakey[/eluser]
Just managed to get this working after spending quite a bit of time messing about. I'm still learning javascript really.

It wasn't too hard in the end. I defined the CSRF value in the controller and made just two changes to the jquery code -

Code:
var token = "&lt;?php echo $ci_token; ?&gt;";    
  $(".target3_editable").editable('&lt;?=base_url()?&gt;dashboard/save-target3', {
      indicator : "<img src='&lt;?=base_url()?&gt;images/indicator.gif'>",
      type   : 'textarea',
      id  : 'target3_id',
      name: 'target3',
      select : true,
      submit : 'OK',
      cancel : 'cancel',
      cssclass : "editable",
      submitdata : {ci_token: token},
      data: function(value, settings) {
          
           return retval;
      }

  });

});

Hope this helps someone with a similar problem!




Theme © iAndrew 2016 - Forum software by © MyBB