freshwebs Posted July 27, 2008 Share Posted July 27, 2008 What is the standard way to pass an associative array of database results from PHP to JavaScript? I basically just need to have an array of data waiting and ready to use to populate a form via JS. I figured my options were to either serialize the array with PHP and then use a JS function to deserialize it. Or I could use XML which seems more JavaScript friendly, but less PHP. Which would be the most efficient way to handle this? Quote Link to comment https://forums.phpfreaks.com/topic/116800-passing-db-results-from-php-to-javascript/ Share on other sites More sharing options...
corbin Posted July 27, 2008 Share Posted July 27, 2008 I would look into JSON and XML and see which one you think would fit the situation better. Chances are, you could use JSON. Also, you could always use delimiting if you're certain the delimiter will never be used, and your data won't contain a new line. Quote Link to comment https://forums.phpfreaks.com/topic/116800-passing-db-results-from-php-to-javascript/#findComment-600668 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.