Jump to content

Need help using CSRF in Codeigniter and Scriptaculous


vincej

Recommended Posts

Hi - My app is built with Codeigniter and so if I turn on CSRF on CI inside the config I get the token being created on my page - good. 

 

But I have 1 page ( "shopping cart") which uses Scriptaculous Ajax.Updater function :  http://api.prototypejs.org/ajax/Ajax/Updater/

 

When I turn on CSRF my shopping cart page refuses to function in terms of updating the cart or deleting any items from the cart. These are both js functions.

 

I am really stuck - any help would be a God send. Thank You !! 

 

Here is the code: 

 

UpDate JS Function: 

function jsUpdateCart(){
  var parameter_string = '';
  allNodes = document.getElementsByClassName("process");
  for(i = 0; i < allNodes.length; i++) {
  	var tempid = allNodes[i].id;
    var temp = new Array;
    temp = tempid.split("_");
 	var real_id = temp[2];
 	var real_value = allNodes[i].value;
    parameter_string += real_id +':'+real_value+',';
  }

  var params = 'ids='+parameter_string;
  var ajax = new Ajax.Updater(
    'ajax_msg','http://localhost/mysite/index.php/welcome/ajax_cart', {method:'post',parameters:params,onComplete:showMessage}
    );

}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.