I tend to use a JSON object for this:
- On the server side, JSON encode your data:
json_encode($data);
- On the JavaScript side, I write a function that takes a JSON object as a parameter and unpack it.
When you unpack the object, you can print the array’s contents into a <DIV>
tag, or where ever you would like on the page (jQuery does a pretty sweet job of this).