这段AJAX代码是什么含义?大家帮看看 [ 新手入门 ]
<div class="row">
<?php echo $form->labelEx($model,'province'); ?>
<?php echo $form->dropDownList(
$model,
'province',
$model->getProvinceList(),array('empty'=>'-请选择-',
'ajax'=>array(
'url'=>Yii::app()->createUrl('member/dynamicCity'),
'data'=>array('pid'=>'js:this.value'),
'update'=>'#Member_city',
),
)
); ?>
<?php echo $form->error($model,'province'); ?>
</div>
共 13 条回复
-
http://www.yiichina.com/topic/614
二级联动下拉菜单。 -
public static function ajax($options) { Yii::app()->getClientScript()->registerCoreScript('jquery'); if(!isset($options['url'])) $options['url']='js:location.href'; else $options['url']=self::normalizeUrl($options['url']); if(!isset($options['cache'])) $options['cache']=false; if(!isset($options['data']) && isset($options['type'])) $options['data']='js:jQuery(this).parents("form").serialize()'; foreach(array('beforeSend','complete','error','success') as $name) { if(isset($options[$name]) && strpos($options[$name],'js:')!==0) $options[$name]='js:'.$options[$name]; } if(isset($options['update'])) { if(!isset($options['success'])) $options['success']='js:function(html){jQuery("'.$options['update'].'").html(html)}'; //这里是update产生的js代码。 unset($options['update']); } if(isset($options['replace'])) { if(!isset($options['success'])) $options['success']='js:function(html){jQuery("'.$options['replace'].'").replaceWith(html)}'; unset($options['replace']); } return 'jQuery.ajax('.CJavaScript::encode($options).');'; }
-
老大帮我看看到底什么地方出问题了,我重新写过一遍你的DemoCity,细节都注意到,而且成功了。
但是想把这个结构应用到我这里来的时候就出问题了,报错PHP500/* * Give Dynamic Project Number List * */ public function actionDynamicProjectNumber($machine_sn) { // $model=Machine::model()->getMachineSnList(); $model = Issue::model()->getProjectNumberList($machine_sn); // $model=Machine::model()->getMachineSnList1(); foreach($model as $value=>$name) { echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true); } } <!-- machine _ s n drop down list--> <div class="row"> <?php echo $form->labelEx($model,'machine_sn'); ?> <?php echo $form->dropDownList( $model, 'machine_sn', Issue::model()->getMachineSnList(), array( 'empty'=>'-请选择-', 'ajax'=>array( 'url'=>Yii::app()->createUrl('Issue/issue/dynamicProjectNumber'), 'data'=>array('machine_sn'=>'js:this.value'), 'update'=>'#Issue_project_number', ), ) ); ?> <?php echo $form->error($model,'machine_sn'); ?> </div> array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=>array('create','update','dynamicProjectNumber'), 'users'=>array('@'), ), public function getMachineSnList () { $currMachineSnList= Machine::model()->findAll(); return cHtml::listData($currMachineSnList,'machine_sn','machine_sn'); } /* * get Machine Project Number * */ public function getProjectNumberList ($machine_sn) { $currProjectNumber= Machine::model()->findAllByAttributes(array('machine_sn'=>$machine_sn)); return cHtml::listData($currProjectNumber,'machine_sn','project_number'); }
-
PHP Error [2]
include(cHtml.php) [function.include]: failed to open stream: No such file or directory (D:\xampp\htdocs\X\framework\YiiBase.php:421)
#0 D:\xampp\htdocs\X\framework\YiiBase.php(421): CWebApplication->handleError() #1 D:\xampp\htdocs\X\framework\YiiBase.php(421): autoload() #2 unknown(0): autoload() #3 D:\xampp\htdocs\X\yii_fox\protected\models\Issue.php(111): spl_autoload_call() #4 D:\xampp\htdocs\X\yii_fox\protected\modules\Issue\controllers\IssueController.php(184): Issue->getProjectNumberList() #5 unknown(0): IssueController->actionDynamicProjectNumber() #6 D:\xampp\htdocs\X\framework\web\actions\CAction.php(104): ReflectionMethod->invokeArgs() #7 D:\xampp\htdocs\X\framework\web\actions\CInlineAction.php(48): CInlineAction->runWithParamsInternal() #8 D:\xampp\htdocs\X\framework\web\CController.php(300): CInlineAction->runWithParams() #9 D:\xampp\htdocs\X\framework\web\filters\CFilterChain.php(134): IssueController->runAction() #10 D:\xampp\htdocs\X\framework\web\filters\CFilter.php(41): CFilterChain->run() #11 D:\xampp\htdocs\X\framework\web\CController.php(1144): CAccessControlFilter->filter() #12 D:\xampp\htdocs\X\framework\web\filters\CInlineFilter.php(59): IssueController->filterAccessControl() #13 D:\xampp\htdocs\X\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter() #14 D:\xampp\htdocs\X\framework\web\CController.php(283): CFilterChain->run() #15 D:\xampp\htdocs\X\framework\web\CController.php(257): IssueController->runActionWithFilters() #16 D:\xampp\htdocs\X\framework\web\CWebApplication.php(277): IssueController->run() #17 D:\xampp\htdocs\X\framework\web\CWebApplication.php(136): CWebApplication->runController() #18 D:\xampp\htdocs\X\framework\base\CApplication.php(158): CWebApplication->processRequest() #19 D:\xampp\htdocs\X\yii_fox\index.php(13): CWebApplication->run()
attajob Shanghai
注册时间:2011-12-09
最后登录:1970-01-01
在线时长:0小时0分
最后登录:1970-01-01
在线时长:0小时0分
- 粉丝0
- 金钱240
- 威望0
- 积分240