Home > Backend Development > PHP Tutorial > jquery和php的关于json有关问题

jquery和php的关于json有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:57:28
Original
941 people have browsed it

jquery和php的关于json问题
a.php从b.php文件中取出json数据,显示到页面div上去,怎么写?

  b.php数据如下
  $arr = array(
'0'=>array('id'=>'1','name'=>'zs','sex'=>'man'),
'1'=>array('id'=>'2','name'=>'ls','sex'=>'women'),
);
  echo json_encode($arr);
  return;

a.php 文件想取到json数据然后循环显示到页面上去效果跟下面差不多:
id name
1 zs
2 ls
最近刚学jquery,还不太会,这个怎么实现?大家帮个忙,谢谢。

------解决方案--------------------
ajax ? 如果不是,则直接 include('b.php'); 操作数组输出你的结构即可。
------解决方案--------------------
这是 js 问题,应该到 javascript 版面求解!

你 $("p").append("

");
那么不就是有很多名为 aaaa 的 id 了吗?
但是 dhtml 的 id 应该是唯一的
------解决方案--------------------
用ajax,里面有个responseText属性,可以获取json数据

然后用jquery就可以显示到div上面去了
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Backslash present in Json
From 1970-01-01 08:00:00
0
0
0
Get: Transfer JSON data
From 1970-01-01 08:00:00
0
0
0
mysql storage json error
From 1970-01-01 08:00:00
0
0
0
javascript - Problems with displaying json data
From 1970-01-01 08:00:00
0
0
0
Find matching integers in JSON.
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template