Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 COMET 所做的事情有了基本的了解(服务器端不断循环,并打印出<script>标签的方式),所以我只是在摆弄它。
<script>
我可以通过这种方式将一个简单的字符串从 PHP 传递到 Javascript,但是 PHP 数组呢?有没有使用这种方法将 PHP 数组传递给 Javascript(将其转换为 JS 数组??)?
JSON 是一种数据格式,它是 JavaScript 的一个子集,其中包括作为数据类型的数组。
请参阅规范和创建它的 PHP 函数。
您可以将数组转换为 JSON,然后将其传递给脚本数据中的 JS。