how do you pass multiple variables from the php to the javascript?

  • Thread starter Thread starter eliyahu_s
  • Start date Start date
E

eliyahu_s

Guest
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?
 
Back
Top