javascript AJAXでphpから2つのID値を取得する方法
test.php
function lc(str) {
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();
}
<p>Output1: <span id="txtHint"></span></p>
<p>Output2: <span id="wrdHint"></span></p>
gethint.php
<?php
$q=$_GET["q"];
if (strlen($q) > 0)
{
$out1=strlen($q);
}
if (str_word_count($q) > 0)
{
$out2=strrev($q);
}
echo $out1;
echo $out2;
?>
Output1 のみが機能してい
ます。Output2 は機能していません。
誰でも私を助けてもらえますか....