ThinkPHP随笔

使用应用分组模式开发程序时,U函数表示地址时,要用这种格式 “项目名/控制器名/方法名”写地址,不能直接使用U("handle")

如:var handleUrl = '{:U("Index/Index/handle",'','')}';

 


if(!IS_AJAX) halt('页面不存在aaa');        IS_AJAX  判断是否为ajax提交过来的

halt() 指定错误信息 {等同于  _404()} 使用 <?php echo $e['message']; ?>接收信息  


//指定错误页面模板路径  在config.php配置
'TMPL_EXCEPTION_FILE' => './Public/Tpl/error.html'


 __APP__  表示项目主页


<script type="text/javascript"> window.onload = function (){ setTimeout(function(){ window.location.href = '<?php echo __APP__; ?>';// //alert (); },1000); }

 


常用公共config.php配置内容:

<?php
return array(
//开启应用分组
'APP_GROUP_LIST' => 'Index,Admin',
//默认分组
'DEFAULT_GROUP' => 'Index',
//数据库连接参数
'USERNAME' =>'XTMP',
'DB_HOST' => '127.0.0.1',
'DB_PWD' => '',
'DB_USER' => 'root',
'DB_NAME' => 'think',
'DB_PREFIX' => 'hd_',

//点语法默认解析
'TML_VAR_IDENTIFY' => 'array' //加快解析速度
);
?>


//异步操作
$.post(handleUrl, {username : username.val(), content : content.val()},
function(data){


},'json');

posted @ 2015-11-19 14:26  虚幻的街景  阅读(122)  评论(0编辑  收藏  举报