js用json调用php并显示返回值
图片1是一个接送记录,图片2是这个记录的一个接口,怎么用js调用这个php然后在网页上显示那些返回值,怎么弄的,php中的代码也附上了。
require('../../../incode/user_fns.php');
function __autoload($class_name) {
require_once '../../../incode/'.$class_name.'.php';
}
if (isset($_COOKIE['userid'])) {
$userid = intval(trim($_COOKIE['userid']));
} else {
error_exit(ENOPOST);
}
if (isset($_COOKIE['token'])) {
$usertoken = trim($_COOKIE['token']);
} else {
error_exit(ENOPOST);
}
if (!$usertoken || !$userid) {
error_exit(ENOPOST);
}
if (isset($_POST['year'])) {
$year = intval(trim($_POST['year']));
} else {
error_exit(ENOPOST);
}
if (isset($_POST['month'])) {
$month = intval(trim($_POST['month']));
} else {
error_exit(ENOPOST);
}
if (!$year || !$month) {
error_exit(ENOPOST);
}
$page = 0;
if (isset($_POST['page'])) {
$page = intval(trim($_POST['page']));
}
$count = 10;
if (isset($_POST['pcount'])) {
$count = intval(trim($_POST['pcount']));
}
try{
db_connect();
$registry =& Registry::getInstance();
$conn =& $registry->get('dbconn');
if (!check_accesstoken($userid, $usertoken)) {
error_exit(EUSERTOKEN);
}
$result = $conn->query("select bbid from user where userid=$userid");
if (!$result) {
error_exit(EDBSELECT);
}
$row = $result->fetch_row();
if (!$row) {
error_exit(EBABYNOTEXIST);
}
$bbid = $row[0];
$result = $conn->query("select cardid from accesscard where bbid=$bbid");
if (!$result) {
error_exit(EDBSELECT);
}
$resultarray = array();
$starttime = strtotime("$year-$month-1");
$month++;
$endtime = strtotime("$year-$month-1");
$pagestart = $page*$count;
$result = $conn->query("select checkid,parent,time,status from checkin where bbid=$bbid and time>$starttime and time
if (!$result) {
error_exit(EDBSELECT);
}
while ($row = $result->fetch_row())
{
if (connection_aborted() || connection_status()!=CONNECTION_NORMAL) {
exit;
}
$lasttime = $row[2];
$checkin['checkid'] = $row[0];
$checkin['parent'] = $row[1];
if (!$row[1]) {
$result1 = $conn->query("select name from user a,checkin b where b.checkid='".$row[0]."' and a.userid=b.cardid");
if (!$result1) {
error_exit(EDBSELECT);
}
$row1 = $result1->fetch_row();
if (!$row1) {
continue;
}
$checkin['teacher'] = $row1[0];
}
$checkin['time'] = $lasttime;
$checkin['status'] = $row[3];
$resultarray[] = $checkin;
}
echo json_encode($resultarray);
}catch (Exception $e) {
error_exit($e->getCode());
}
?>
相关阅读:
APP使用支付宝/微信支付如何在没有APP情况下进行调试?
textarea js赋值问题,为什么 value 和 innerHTML 都不行??
sijax register_upload_callback 传递参数问题
关于布局的几个疑问?
滚动到达内容区域相应的触发右边选中怎么做
浏览器端同时请求100个url后,如何提升有效的msyql连接数
导入MaterialDesignLibrary后报错
连接远程服务器上开发,mount 的效率高还是 sftp 的效率高?
病狗算题,代码
background-img之间有很小的缝隙
求思路?用OC编通讯录增啥改查的问题?
AJAX ajax从一位朋友那分享一些ajax的小心得
pop一个视图控制器后内存没有完全释放?
OC中的方法加锁
xcode的file reference 有什么用?
sass编译遇到 @media screen\0失败
【redis存储结构设计】存储坐标点及其多维度点击数
slim框架如何使用视图和模板
node如何获取当前文件的上级目录路径?
css中font简写的偷懒问题