1、从前端的角度:增加遮罩
2、从后端的角度:使用session
$session = Yii::app()->session; $user_id = Yii::app()->user->id; $sessionKey = $user_id.'_is_sending'; if(isset($session[$sessionKey])){ $first_submit_time = $session[$sessionKey]; $current_time = time(); if($current_time - $first_submit_time < 10){ $session[$sessionKey] = $current_time; $this->response(array('status'=>1, 'msg'=>'不能在10秒钟内连续发送两次。')); }else{ unset($session[$sessionKey]);//超过限制时间,释放session"; } } //第一次点击确认按钮时执行 if(!isset($session[$sessionKey])){ $session[$sessionKey] = time(); }