不知道如何把php数组传js

WBOY
Release: 2016-06-23 14:39:12
Original
1001 people have browsed it

$webdata[a]='111';
$webdata[b]='222';
$webdata[c]='333';
$webdata[d]='444';
echo "$webdata";
?>


<script> <br /> function getResult(webdata){ <br /> var abc=webfile; <br /> $("#aaa").val(abc[0]); <br /> $("#bbb").val(abc[1]); <br /> $("#ccc").val(abc[2]); <br /> $("#ddd").val(abc[3]); <br /> } <br /> </script>








php输出一个数组给js,js如何把数组中数据 添加到input中,


回复讨论(解决方案)

php与js的桥梁搭建好了是吗? js可以取到php的 值了吗。建议你用json比较方便。

ajax 请求PHP,可以获取得到

建议使用ajax异步请求php。php返回json。js。来解析json

谢谢各位 ,OK了,

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!