Home > Backend Development > PHP Tutorial > php,js,处理数组有关问题

php,js,处理数组有关问题

WBOY
Release: 2016-06-13 10:09:29
Original
1005 people have browsed it

php,js,处理数组问题
小弟初学者,有些不明白,我用ajax处理PHP后返回这样的数组
Array
(
  [0]=>Array
  (
  [0]=>2
  [id]=>2
  [1]=>张三
  [name]=>张三
  ) 
  [1]=>Array
  (
  [0]=>3
  [id]=>3
  [1]=>李四
  [name]=>李四
  ) 
)
Ajax返回的值value用JS怎么取不出数组的值呢,value[0][0]这样取有错吗?怎么取出来的值是A呢

------解决方案--------------------
建议搜索一下PHP AJAX返回JSON数据的实例。
------解决方案--------------------
把你返回的数组,用json_encode()函数处理一下,再返回给前端js使用,应该不会出错了
------解决方案--------------------
最好转为json格式的。用js接收才比较方便。

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template