Today,I meet a question and it confused me.follow my codes:
this is the view file manage.php
<table class='box_basic'>
<tr>
<td>Blog Name</td><td><?=CHtml::textField('blogname',$bloginfo->title,array('id'=>'blogname'))?></td><td><?=CHtml::ajaxLink('修改',CController::createUrl('/blog/site/change',array('id'=>$bloginfo->id,'o'=>'title')),array('type'=>'POST','data'=>"v=$('#blogname').val()",'success'=>'function(data){alert(data);}'))?>
</td>
</tr>
</table>
this is the action and the content just for test
public function actionChange(){
$id = Yii::app()->request->getQuery('id',null);
$operation = Yii::app()->request->getQuery('o',null);
$value = Yii::app()->request->getPost('v');
if($id === null){
throw new CHttpException('404','invalidate operation');
}
$blog = Blog::model()->findByPK('id');
$blog->title = $value;
if($blog->save())
echo 'change successful';
}
i find the data option of ajax can’t recognize js script,if i wanna get the value of textField ,what can i do?