返回列表 发新帖
查看: 640|回复: 0

[Discuz!二次开发] Discuz X helper_output_demo

[复制链接]

6671

热度

1万

元宝

262

贡献

管理员

DZ专员

发表于 2015-3-26 09:43:58 | 显示全部楼层 |阅读模式
<?php
if($_GET['action'] == 'getJSON') {
        helper_output::json(array('description'=>'我是JSON数据', 'datalist' => array('数据1', '数据2', '数据3')));
} else if($_GET['action'] == 'getHTML') {
        helper_output::html('<div>我是HTML</div>');
} else if($_GET['action'] == 'getdata') {
        helper_output::xml('我是XML数据');
}
?>

<script>
var x = new Ajax();
x.getJSON('forum.php?mod=misc&action=getJSON', function(s) {
        //JSON数据错误时,s为null
        if(s !== null) {
                //code
                alert(s);
        }
});

var x2 = new Ajax();
x2.getHTML('forum.php?mod=misc&action=getHTML', function(s) {
        //code
        alert(s);
});

var x3 = new Ajax();
x3.get('forum.php?mod=misc&action=getdata', function(s){
        alert(s);
});
</script>

helper_output_demo.php (714 Bytes, 下载次数: 4)


来自建站学习研究资源开放平台【www.cgzz8.cn
返回列表 发新帖
 懒得打字嘛,点击右侧快捷回复【最新发布】   【赞助草根吧享更多权益】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

收藏帖子 返回列表 搜索

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

小黑屋|手机版|草根吧