aooga Posted April 5, 2009 Share Posted April 5, 2009 I'm using php and Javascript together with AJAX. I want my php script to return 3 sets of data to my javascript function stateChanged(). I want some data to go into the innerHTML of document.getElementById("question"), some into document.getElementById("answer"), and some into document.getElementById("answer2"). Right now, the best way I can think of is to echo from within my php file: echo "<question>this is the question here</question>"; echo "<answer>this is the answer</answer>"; echo "<answer2>this is the answer2</answer2>"; and then use regular expressions within the javacript to parse the file and process it. Is there an easier way? Link to comment https://forums.phpfreaks.com/topic/152658-how-do-you-pass-multiple-variables-from-the-php-to-the-javascript/ Share on other sites More sharing options...
xtopolis Posted April 6, 2009 Share Posted April 6, 2009 Put it in JSON format http://www.secretgeek.net/json_3mins.asp Link to comment https://forums.phpfreaks.com/topic/152658-how-do-you-pass-multiple-variables-from-the-php-to-the-javascript/#findComment-801922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.