Jump to content

Passing DB results from PHP to JavaScript


freshwebs

Recommended Posts

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.