Hello!
I enabled CSRF validation and normal form can work, but I cant make a request with ajax.
I need to check automatically for new messages on the db without user interaction,
tried to use the getCrsfToken () but did not work.
I get the message:
Bad Request
The CSRF token can not be verified.
The request could not be understood by the server due to malformed syntax. Please do not repeat the request without modifications.
If you think this is a server error, please contact the webmaster.
Does anybody know the solution?
Thanks!
yoshi
(Jaschakoch)
2
Hi,
maybe the code how you are doing this would help finding a solution…
Did you include a variable named as the token-name with the value of the token in your ajax POST request?
Regards
Ismael
(Shalanga)
3
http://www.yiiframework.com/doc/api/CHtml#ajaxLink-detail
in array $ajaxOptions=array:
ajaxLink(‘x’, ‘y’, array(‘csrf’ => true));
Dave
(Deventer)
4
what are your session options? you can not use cookie secure if you want to pass the csrf token through ajax.