Welcome Guest, Not a member yet? Register   Sign In
Ajax - CSRF
#8

[eluser]SPeed_FANat1c[/eluser]
It sucks a little to repeat the same line in javascript when we want to post data. Isn't there some automatic way - when we use ajax post method - to automatically include ci_csrf_token into data?

one solution comes to my head would be to write a function something like this:

pseudocode:
Code:
function my_post(url, success_callback, post_data)
{
   var post_data_with_protection = {ci_csrf_token: ci_csrf_token};
   //formate the data arry
   foreach (post_data as post) {
      post_data_with_protection[] = post;
   }
  
   $.post(url, post_data_with_protection, success_callback);

}

what do you think? Or is there better solutions?


Messages In This Thread
Ajax - CSRF - by El Forum - 07-05-2011, 01:00 PM
Ajax - CSRF - by El Forum - 07-05-2011, 04:35 PM
Ajax - CSRF - by El Forum - 07-06-2011, 01:53 AM
Ajax - CSRF - by El Forum - 07-06-2011, 05:10 AM
Ajax - CSRF - by El Forum - 07-06-2011, 05:41 AM
Ajax - CSRF - by El Forum - 07-06-2011, 06:19 AM
Ajax - CSRF - by El Forum - 07-06-2011, 07:04 AM
Ajax - CSRF - by El Forum - 07-30-2011, 12:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB