您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Ajax请求json数据

2025/11/8 16:03:25发布35次查看
同域请求json数据
客户端js代码:

view code服务端端php代码:
function in_goodslist() { $callback = $this->fun->accept('callback', 'g'); $db_table = db_prefix . 'advert'; $db_where = ' where isclass=1 and atid=6'; $bann_array = array(); $sql = select * from $db_table $db_where order by pid,adid desc limit 0,10; $rs = $this->db->query($sql); while ($rslist = $this->db->fetch_assoc($rs)) { if ($rslist['islink'] == 2 && $rslist['gotoid'] > 0) { $docread = $this->get_documentview($rslist['gotoid']); if ($docread['did'] > 0) $rslist['url'] = $this->get_link('doc', $docread, $lngpack); } if ($rslist['istime'] == 1) { if ($rslist['starttime'] time() && $rslist['endtime'] > time()) { $bann_array[] = $rslist; } } else { $bann_array[] = $rslist; } } $json = json_encode($bann_array); //$json = $bann_array; echo $callback.($json); }
view code跨域请求json数据
客户端js代码:

view code服务端php代码:
function in_goodslist() { $callback = $this->fun->accept('callback', 'g');//get 封装 $db_table = db_prefix . 'advert'; $db_where = ' where isclass=1 and atid=6'; $bann_array = array(); $sql = select * from $db_table $db_where order by pid,adid desc limit 0,10; $rs = $this->db->query($sql); while ($rslist = $this->db->fetch_assoc($rs)) { if ($rslist['islink'] == 2 && $rslist['gotoid'] > 0) { $docread = $this->get_documentview($rslist['gotoid']); if ($docread['did'] > 0) $rslist['url'] = $this->get_link('doc', $docread, $lngpack); } if ($rslist['istime'] == 1) { if ($rslist['starttime'] time() && $rslist['endtime'] > time()) { $bann_array[] = $rslist; } } else { $bann_array[] = $rslist; } } $json = json_encode($bann_array); echo $callback.($json); }
view code 以上就介绍了ajax请求json数据,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product