Yii Framework Forum: How to submit via ajaxLink? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to submit via ajaxLink? Rate Topic: -----

#1 User is offline   lenye 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 04-February 10

Posted 07 June 2010 - 03:00 AM

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?
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 07 June 2010 - 03:16 AM

Put "js:" in front of the javascript code...

similar post - http://www.yiiframew...__fromsearch__1
Find more about me.... btw. Do you know your WAN IP?
1

#3 User is offline   lenye 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 04-February 10

Posted 07 June 2010 - 03:28 AM

 mdomba, on 07 June 2010 - 03:16 AM, said:

Put "js:" in front of the javascript code...

similar post - http://www.yiiframew...__fromsearch__1

thank you! it does work perfectly! :lol:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users