Home > Backend Development > PHP Tutorial > js传接二维数组给php

js传接二维数组给php

WBOY
Release: 2016-06-13 12:21:35
Original
1253 people have browsed it

js传递二维数组给php
以前使用js给php传参都是传的string类型的,今天需要用ajax传递一个二维数组给php,不知道怎么做,请教各位高手们。



------解决思路----------------------

------解决思路----------------------
例子:

<br />    <script type="text/javascript"><br />    $.post("server.php",{name:[[1,2],[3,4]]})<br />      .done(function(data){<br />        alert(data[0][1]); // 输出2<br />      });<br />    </script><br />
Copy after login


server.php
<br />header('content-type:application:json;charset=utf8');<br />echo json_encode($_POST['name']);<br />
Copy after login

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