Как получить другое значение переменной в разных идентификаторах из ответа ajax.
В моем программировании получить все ответы из файла test.php
, но я хочу по-разному для обеих переменных.
Файл Index.php: -
<html>
<span> Picture : </span>
<!-- In picture hint i want to print $varbilefirst value from test.php file -->
<span id="picturehintget"></span>
<input type="button" id="<?php echo "8"; ?>" class="submitnone" name="ansclick" onclick="QuestionId(this.id)" value="Submit">
<div> Demo : <p id="demoquiz"></p> </div>
<!--In Demo i want to print $varbilesec value from test.php file -->
<script type="text/javascript">
function QuestionId(obj)
{
var id = obj;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function ()
{
if (this.readyState == 4 && this.status == 200)
{
document.getElementById("demoquiz").innerHTML = this.responseText;
document.getElementById("picturehintget").innerHTML = this.responseText;
}
};
xhttp.open("GET", "test.php?id=" + id, true);
xhttp.send();
}
</script>
</html>
test.php file
<?php
$id = $_GET['id'];
$varbilefirst = "For Picture Hint";
echo $varbilefirst;
$varbilesec = "For Demo Hint";
echo $varbilesec;
?>
Я хочу совершенно другое значение переменной для разных идентификаторов.
<span id="picturehintget">For Picture Hint</span>
<p id="demoquiz">For Demo Hint</p>