justcode316 发表于 2013-1-29 13:23:41

zend framework jquery

在public下创建js文件将jquery.js拷贝进去Controller部分public function getroleAction(){$role = new Role();$result = $role->fetchAll()->toArray();//二维数组//print_r($result);//一维数组//$result = []; //$result['name'] = "xxoo"; //$result['email'] = "justcode@126.com"; echo Zend_Json::encode($result); exit;}view部分引入<script type="text/javascript" src="/js/jquery.js"></script>//角色下拉选择框的处理$.ajax({type:"post",url:'/center/getrole',//data:{value:name,column:'ID'},success:function(data){//得到二维数组   var obj = jQuery.parseJSON(data);   var optionstring = "";   for (var i = 0; i < obj.length; i++) {   if(obj.id == <?=$this->user['role']?>){optionstring += "<option value=\"" + obj.id + "\" selected='selected'>" + obj.name + "</option>";    }else{optionstring += "<option value=\"" + obj.id + "\" >" + obj.name + "</option>";    }   }    $("#role_").html(optionstring);//alert(obj.name);一维数组取值//alert(obj.email);}});
页: [1]
查看完整版本: zend framework jquery