Reputation: 5039
I use a few different AJAX calls in one of my pages through a couple of different methods.
CHtml::link()
CHtml::ajax()
CGridview
Since enabling CSRF I'm having difficulty verifying the token. What is the correct way? I've read a few posts, but struggling to implement. For instance in CHtml::link()
I've tried:
'data' => "Yii::app()->request->csrfTokenName = Yii::app()->request->csrfToken",
and also within CGridview
:
data: {
Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken
},
Upvotes: 4
Views: 6466
Reputation: 1136
1- Fot ajax you have ajax, ajaxLink and ajaxButton not just link.
2- CSRF token works when you use POST request
3- Add CSRF token like this:'data'
=>array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken)`
Upvotes: 4