Home  >  Article  >  Backend Development  >  js传送字符串数组到php

js传送字符串数组到php

WBOY
WBOYOriginal
2016-06-13 12:32:131263browse

js传递字符串数组到php
为什么从js传递的字符串数组在php中变成了一个字符串,ajax传递的,代码如下:
js端:
var selected = new Array('1','2');
JSON.stringify(selected);
post....

php端:
$selected = json_decode($_POST['selected']);
这样写$selected是空的 
$selected = $_POST['selected'];
这样的话$selected便是一个字符串,我要的是数组。

求助各位了,折腾好久了。。。

js php
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