Possible Duplicate:
convert php array to javascript array
passing PHP objects to javascript
Greetings Stackoverflow
I'm in quite a problem, I want to pass an array of objects from PHP to Javascript for processing. How could I do this. Tnx in advance
Possible Duplicate:
convert php array to javascript array
passing PHP objects to javascript
Greetings Stackoverflow
I'm in quite a problem, I want to pass an array of objects from PHP to Javascript for processing. How could I do this. Tnx in advance
Often this is done using an Ajax call to your PHP app, and have PHP generate JSON with the data being sent for processing (see json_encode()).
I've also seen PHP programs generate the JavaScript with the data encoded directly in the script, but I would not recommend this approach.
When echoing the javascript in the view, you can use echo json_encode($array) to convert the PHP array to JSON which can then be inserted into a javascript variable.