Home >Backend Development >PHP Tutorial >ajax 二维数组,该怎么处理

ajax 二维数组,该怎么处理

WBOY
WBOYOriginal
2016-06-13 11:45:54817browse

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

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

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

Statement:
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