Jump to content

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


aooga

Recommended Posts

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?

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.