How to set the jump waiting time for thinkphp page jump (successerror)_PHP tutorial

WBOY
Release: 2016-07-13 10:31:05
Original
1832 people have browsed it

thinkphp 3.1.2 The default waiting time for template jump is only 3 seconds, which is very troublesome when you want to see error messages during development, although it can be displayed on the page through $this-> ;assign('waitSecond','1') Customize the page jump waiting time, but it always feels very troublesome. Is there a way to change the default 3 seconds to a longer time? The following will teach you how to define this time as how long you want to wait. In thinkphp 3.1.2, find the Action.class.php file in LibCore in the system directory, find the dispatchJump method below, and find $ this->assign('waitSecond','3' Just change the 3 inside.

/**
 * 默认跳转操作 支持错误导向和正确跳转
 * 调用模板显示 默认为public目录下面的success页面
 * 提示页面为可配置 支持模板标签
 * @param string $message 提示信息
 * @param Boolean $status 状态
 * @param string $jumpUrl 页面跳转地址
 * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
 * @access private
 * @return void
 */
private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) {
	if(true === $ajax || IS_AJAX) {// AJAX提交
		$data           =   is_array($ajax)?$ajax:array();
		$data['info']   =   $message;
		$data['status'] =   $status;
		$data['url']    =   $jumpUrl;
		$this->ajaxReturn($data);
	}
	if(is_int($ajax)) $this->assign('waitSecond',$ajax);
	if(!empty($jumpUrl)) $this->assign('jumpUrl',$jumpUrl);
	// 提示标题
	$this->assign('msgTitle',$status? L('_OPERATION_SUCCESS_') : L('_OPERATION_FAIL_'));
	//如果设置了关闭窗口,则提示完毕后自动关闭窗口
	if($this->get('closeWin'))    $this->assign('jumpUrl','javascript:window.close();');
	$this->assign('status',$status);   // 状态
	//保证输出不受静态缓存影响
	C('HTML_CACHE_ON',false);
	if($status) { //发送成功信息
		$this->assign('message',$message);// 提示信息
		// 成功操作后默认停留1秒
		if(!isset($this->waitSecond))    $this->assign('waitSecond','1');
		// 默认操作成功自动返回操作前页面
		if(!isset($this->jumpUrl)) $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]);
		$this->display(C('TMPL_ACTION_SUCCESS'));
	}else{
		$this->assign('error',$message);// 提示信息
		//发生错误时候默认停留3秒
		if(!isset($this->waitSecond))    $this->assign('waitSecond','3');
		// 默认发生错误的话自动返回上页
		if(!isset($this->jumpUrl)) $this->assign('jumpUrl',"javascript:history.back(-1);");
		$this->display(C('TMPL_ACTION_ERROR'));
		// 中止执行  避免出错后继续执行
		exit ;
	}
}
Copy after login

Articles you may be interested in

  • Summary of page timing jump (countdown jump) code
  • How to load javascript on the page to improve website performance
  • Set the default homepage of the website through .htaccess
  • PHP class for calculating program running time
  • Usage of several keywords such as $this, static, final, const, self, etc. in php
  • Use the PHP function memory_get_usage to obtain the current PHP memory consumption to optimize program performance
  • The last record in the thinkphp template to determine the volist loop
  • .htaccess How to set up anti-leeching Pictures of catalog

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764154.htmlTechArticlethinkphp 3.1.2 The default waiting time for template jump is only 3 seconds. This is useful if you want to see error messages during development. It is very troublesome, although it can be displayed on the page through $this-a...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template