views:

142

answers:

1

I got a basic gist of what COMET does (the constant looping on server side, and printing out <script> tags way), so I am just fiddling with it.

I can pass a simple string from PHP to Javascript that way, but what about PHP arrays? Is there anyway to pass a PHP array to Javascript (casting it to a JS array??) using this method??

+1  A: 

JSON is a data format that is a subset of JavaScript, that includes arrays as a data type.

See the specification and the PHP function for creating it.

You can convert your array to JSON and then pass it to JS in your script data.

David Dorward