ThinkPHP jump page success and error template instance tutorial

Source: Internet
Author: User
This article mainly introduces ThinkPHP jump page success and error template instance tutorials, which can help beginners to further familiarize themselves with the page jump process of ThinkPHP, for more information about how to implement the view and controller corresponding to the success and error methods on ThinkPHP jump pages, this example helps you better understand the use of the success and error methods.

First, you can use the following code in the controller:

<? Php // This document is automatically generated. it is only for testing and running class IndexAction extends Action {/** + ------------------------------------------------------ * default operation + functions */public function index () {$ this-> assign ("title", "water purifier"); $ User = M ("User "); // instantiate the User object $ result = $ User-> add ($ data); if ($ result) {// after successful settings, the default return page is $ _ SERVER ["HTTP_REFERER"] $ this-> assign ("jumpUrl", "index "); $ This-> success ("added successfully! ");} Else {// The default jump page of the error page is to return to the previous page. Generally, you do not need to set $ this-> error (" New error! ") ;}$ This-> display () ;}}?>

Success.html: Tpl \ default \ Public \ success.html

 
 Successful message
 
 
Success message prompt
{$ Message}
Title information processed successfully: {$ msgTitle}
Custom success message: {$ message}
Custom error message: {$ error}
Jump page path: {$ jumpUrl}
Stay Time: {$ waitSecond}
2 seconds later, return to the specified page!
If the browser cannot jump, click here.

Error page location: Tpl \ default \ Public \ success.html

 
 Successful message
 
 
Error message prompt
{$ Message}
Title information processed successfully: {$ msgTitle}
Custom success message: {$ message}
Custom error message: {$ error}
Jump page path: {$ jumpUrl}
Stay Time: {$ waitSecond}
2 seconds later, return to the specified page!
If the browser cannot jump, click here.

The Success and error methods both have corresponding templates and can be set. the default settings are Public: success and Public: error. template labels can be used for template files, you can also use the following template variables:

$ MsgTitle: Operation title
$ Message: page prompt information
$ Status: Operation status 1 indicates success. 0 indicates failure. you can also define rules for the project.
$ WaitSecond: the unit of the jump wait time is wonderful.
$ JumpUrl: Jump page address
If the request is submitted in AJAX mode, the success and error methods call the ajaxReturn method to return information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.