小草根

Discuz X helper_output_demo

作者:小草根   发布时间:2015-03-26 09:43   回复数:0   浏览数:638
小草根
6380小草根管理员
2015-03-26 09:43:58
6380 2015-03-26 09:43:58
话题: discuz
<?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


来自建站学习研究资源开放平台【www.cgzz8.cn
游客
登录后才可以回帖,登录 或者 注册