Home > php教程 > php手册 > ajax与PHP 传参问题

ajax与PHP 传参问题

WBOY
Release: 2016-06-06 19:42:30
Original
869 people have browsed it

可以在PHP端把多个参数封装成一个对象。比如 $people['age'] = "21"; $people['gender'] = "male"; $people['phoneNum'] = "12345678"; 然后 echo json_encode($people); json_encode()函数的作用是把$people打包成一个JSON结构的对象。 然后在js端用eval(

可以在PHP端把多个参数封装成一个对象。比如

$people['age'] = "21";

$people['gender'] = "male";

$people['phoneNum'] = "12345678";

然后 echo json_encode($people);

 json_encode()函数的作用是把$people打包成一个JSON结构的对象。

然后在js端用eval()函数将JSON结构解析成一个对象,就可以用obj.age或者obj.phoneNum的形式调用PHP传过来的参数了。

详细的例子可以看这个:

http://www.cnblogs.com/elaron/archive/2010/11/16/1878369.html

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template