CodeIgniter Forums
Including More Data in an AJAX Post with CSRF Enabled - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Including More Data in an AJAX Post with CSRF Enabled (/showthread.php?tid=44091)



Including More Data in an AJAX Post with CSRF Enabled - El Forum - 08-02-2011

[eluser]Doulos[/eluser]
OK, So here's the javascript, I have 9 Elements I need to POST at the same time with Ajax, 1 of which is the CSRF token.
Code:
tx = $("tx"+working_row).val;
mods = $("mods"+working_row).val;
pos = $("pos"+working_row).val;
startdate = $("startdate"+working_row).val;
enddate = $("enddate"+working_row).val;
fordx = $("4dx"+working_row).val;
qty = $("qty"+working_row).val;
price = $("price"+working_row).val;
token = $.cookie("csrf_cookie_name")

obj = {'csrf_token_name': token, 'tx': tx};

$.post("index.php/auth/fee_schedule",obj, function(data){
     alert(data);
});

So, I'd like to include them all in the obj variable and throw that in the call, but whenever I add anything to the obj variable, say 'tx':tx it gives me error 500 Not Allowed. With only the CSRF token in the Obj variable it works just fine.

What am I missing?

thanks!


Including More Data in an AJAX Post with CSRF Enabled - El Forum - 08-02-2011

[eluser]Doulos[/eluser]
Problem was my inability to use the value function from Jquery correctly. Needed () after each .val.