Home > Backend Development > PHP Tutorial > ajax 二维数组

ajax 二维数组

WBOY
Release: 2016-06-23 14:39:52
Original
878 people have browsed it

我用ajax 传递一个参数给PHP页面 需要返回一个二维数组 然后在把它遍历出来 返回来的是JSON
我不知道 怎么把它变成PHP数组 用foreach遍历出来 求指教


回复讨论(解决方案)

<script type="text/javascript">	$(function(){		$.post('index.php',{}, function(data){			var data = eval('(' + data + ')');  //对返回值进行转化			for(var key in data){				console.log(data[key]);//第一层数组				for(var i in data[key]){					console.log(data[key][i]);第二层				}			}		});	});</script>
Copy after login

返回来的json进行解析,再for循环

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