Original: thinkphp page jump, Ajax tips Detailed Introduction (18)
thinkphp page jump, Ajax tips Detailed Introduction
First, page jump
$this->success (' query success ', U (' user/test '));
├─//Jump Current Module method:
├─ $this->success (' Query succeeded ', ' test ');
└─//jump to the specified jump module method
This->success (' query succeeded ', U (' user/test '));
$this->error (' query failed, 3 seconds after the jump will be before the page/previous page ');
Redirect to the category operation of the new module
$this->redirect (' new/category ', ', 5, ' page jump ... ');
Second, Ajax skills
Status Operation state
Info Tip Information
Data returned
$this->ajaxreturn (return data, prompt information, operation status);
Examples of Use:
Module: IndexAction.class.php
<?php
Use of Ajax
Class Indexaction extends Action {
Public Function index () {
$this->display ();
}
Public function
Getajax(){
The value of the pass can be found in the table data Ah ....
$this->ajaxreturn (' Le June Yang gives you the data information returned by Ajax ', ' Information 1 ', 1);
}
}
?>
corresponding Index.html page
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>Index</title>
<script src= "__public__/js/jquery.js" ></script>
<script>
$ (function () {
$ (' button '). Bind (' click ', function () {
$.get ('
__url__/getajax', function (jdata) {
Print out the values to see
Alert (Json.stringify (Jdata));
if (jdata.status==1) {
$ (' div#
did'). HTML (jdata.data);
}
});
});
});
</script>
<body>
<div style= ' height:50px;background:yellow ' id= '
did' ></div>
<button>ajax Click to get Data dynamically </button>
<script>
document.write (New Date ());
</script>
</body>
thinkphp page jump, Ajax tips in detail (18)