YII 的 JQUERY 的json 运用方法
1. php中建立数组
$chage[‘fieldid’] = $fieldid;
$chage[‘butflag’] = 0;
echo CJSON::encode($chage);
2. JS文件中输出
var Jsonstr = $.json.decode(msg);
这样就可以取值Jsonstr[‘fieldid’]
———————————————————————————————–
YII 不用自带的php validate验证功能,自己可以模仿输出
1. 在php中
先用数据库查询用户是否存在
if($this->checkEmail($_POST[’email’]))
{
$error[0] = ’email already exists’;
$er = true;
}
if($er) // 如果存在返回到首页
{
$questions = $this->loadQuest();
$this->render(‘index’, array(
‘post’ => $questions,
‘error_msg_email’ => $error[0],
‘error_msg_zip’ => $error[1],
‘firstname’ => $_POST[‘firstname’],
’email’ => $_POST[’email’],
‘zipcode’ => $_POST[‘zipcode’],