Getting Database Data to the client side.
Posted
by Toby Allen
on Stack Overflow
See other posts from Stack Overflow
or by Toby Allen
Published on 2010-06-08T21:55:00Z
Indexed on
2010/06/08
22:02 UTC
Read the original article
Hit count: 203
I'm sure this has been asked a million times, but what is the accepted approach to this?
I have been writing php code for a while and up until recently I only copied+pasted javascript code, but now with help from YUI I've begun to understand javascript and want to use it more in an existing web app I have. I want to get various amounts of data from databases etc to the clientside javascript. I have access to this data in my php pages when loading.
What is the correct way to get this data to my client side script.
- Generate clientside javascript in my php or smarty template files inserting the data where I need it?
- Use an Ajax call to retrieve the information I need from a php file - returning JSON data?
- Generate a JSON data construct of the data needed by the page and either return it via a script inclusion or dumping it to the generated page?
- Something really obvious I haven't thought of.
© Stack Overflow or respective owner