MPeli
(Martin Pelak)
1
Hi,
I am trying to set data in beforeSend function.
echo CHtml::ajaxLink('', Yii::app()->createUrl('Ajax/UserRestaurant'),
array( // ajaxOptions
'data' => array(),
'beforeSend'=>"function(xhr, s) {
s.data += \"&newProp=newValue\";
}",
),
array( //htmlOptions
'id' => 'star',
)
);
However, no data is sent. What do I do wrong?
Thank you, Martin.
rudenich
(Rudenich)
2
I think, this is possible only for post request.
MPeli
(Martin Pelak)
3
This works fine. Thank you for your help.
echo CHtml::ajaxLink('', Yii::app()->createUrl('Ajax/UserRestaurant'),
array( // ajaxOptions
'beforeSend'=>"function(xhr, s) {
s.data += '&rid=1';
}",
'type' => 'post',
'dataType' => 'jsonp',
'contentType' => 'application/x-www-form-urlencoded; charset=UTF-8'
),
array( //htmlOptions
'id' => 'star',
)
);