ThinkPHP页面跳转、Ajax技巧详细介绍(十八)
来源:互联网 发布:高速数据电台 编辑:程序博客网 时间:2024/05/21 17:33
ThinkPHP页面跳转、Ajax技巧详细介绍
一、页面跳转
$this->success('查询成功',U('User/test'));├─//跳当前模块方法下:
├─ $this->success('查询成功','test');
└─//跳到 指定跳转模块方法下
this->success('查询成功',U('User/test'));
$this->error('查询失败,3秒后跳会之前的页面/上一页');
////重定向到New模块的Category操作
$this->redirect('New/category','',5,'页面跳转中...');
二、Ajax技巧
status 操作状态
info 提示信息
data 返回数据
$this->ajaxReturn(返回数据,提示信息,操作状态);
使用例子:
模块:IndexAction.class.php
<?php
// ajax的使用
class IndexAction extends Action {
public function index(){
$this->display();
}
public function getAjax(){
//传的值可以是表里面查出来的数据啊。。。。
$this->ajaxReturn('乐杨俊给你Ajax返回的数据信息撒','信息1',1);
}
}
?>
对应index.html页面
<html>
<head>
<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){
//把值打印出来看看
alert(JSON.stringify(jdata));
if(jdata.status==1){
$('div#did').html(jdata.data);
}
});
});
});
</script>
</head>
<body>
<div style='height:50px;background:yellow' id='did'></div>
<button>ajax点击动态获取数据</button>
<script>
document.write(new Date());
</script>
</body>
</html>
0 0
- ThinkPHP页面跳转、Ajax技巧详细介绍(十八)
- thinkphp 分组、页面跳转与ajax
- thinkphp使用ajax提交后怎么做页面跳转
- thinkphp 页面跳转不显示问题 data-ajax="false"
- ThinkPHP使用分组详细介绍(十七)
- Thinkphp中页面的跳转
- thinkphp 页面跳转传递参数
- Thinkphp页面跳转设置跳转等待时间
- ajax页面实现跳转
- AJAX跳转页面
- ajax执行页面跳转
- ThinkPHP 页面请求和AJAX
- ThinkPHP框架视图详细介绍 View 视图--模板(九)
- thinkPHP底层设置跳转404页面
- ThinkPHP页面跳转success与error方法
- ThinkPHP 页面跳转和重定向
- ThinkPHP使用success,error页面跳转问题
- ThinkPHP MVC工作原理以及跳转页面
- 00muduobegin
- OpenGL学习之材质RGB值和光源RGB值关系
- Easyui1.4使用FORM表单无法sumbit提交(待解决)
- PCB布线6大原则
- 使用valgrind检查内存问题
- ThinkPHP页面跳转、Ajax技巧详细介绍(十八)
- android初学------关于Eclipse adb 问题"you must restart adb and eclipse“
- URL中出现#号
- Druid数据源的配置
- THINKPHP3.2.2添加行为扩展
- oracle性能调整的十大要点
- LeetCode:Jump Game
- ActiveReports 报表控件 : 导出 PDF、Word 和 Excel文件到客户端
- oracle vm virtualBox共享文件夹功能(记得开启允许远程)