Hello all
Probably my action for ajax star rating fails to save data into db.
I’ve got ajax star rating in my view
$this->widget('CStarRating', array(
'id' => $data->id,
'attribute' => 'rating',
'name' => 'rating[' . $data->id . ']',
'value' => $data->rating,
'callback' => '
function(){
$.ajax({
type: "POST",
url: "' . Yii::app()->createUrl('line/starRatingAjax') . '",
data: { id: "' . $data->id . '" , rate: "$(this).val()"},
success: function(){
$("#result' .$data->id. '").fadeIn().text("Thanks for vote !");
}})}'
));
And an action in my controller :
public function actionStarRatingAjax() {
if (Yii::app()->request->isAjaxRequest) {
$model = $this->loadModel($_POST['id']);
$model->rating = $_POST['rate'];
$model->save();
}
}
It actually views success message but that’s all.
Thank you in advance.