By bigbman on
I just need a simple example of how to pass an array of strings to and from a php page using AJAX. Anyone wanna chime in?
I just need a simple example of how to pass an array of strings to and from a php page using AJAX. Anyone wanna chime in?
Comments
The X in AJAX
I think you're looking at XML. Not hard to do- try google. It's not a Drupal-specific question.
On a more helpful note, if you have REALLY simple strings, you could just concatenate them with e.g. returns in between to pass back and forth.
But I think you'll find XML easier. Look at the example for whatever AJAX toolkit you are using.
-- Version Control your Drupal web site with The File High Club's Free Trial!
drupal_to_js() (in PHP) and parseJson ( in drupal.js)
Steps:
HTTPPost(db.uri, db.receive, db, {'href' : db.href});For some examples see the Javascript Tools package's modules, e.g., Activemenu.
Drupal doesn't however have built in tools to return the data from a JSON array or other data structure to PHP. For that you could use e.g. PEAR's Services_JSON package, http://pear.php.net/pepr/pepr-proposal-show.php?id=198