私の問題は、POST/GET を介して 1 つのパラメーターをプッシュしようとしていることです。このパラメーターは、次のコードで js 関数に渡されます。このファイルはすべて同じディレクトリにあります。
助けを求めて、答えます。よろしくお願いします。
<div id="sidebar"> <?php include('showContent.js'); ?>
<ul>
<li>
<h2>TITLE</h2>
<ul>
<li><a onclick="showContent('1');">Link1</a></li>
<li><a onclick="showContent('2');">Link2</a></li>
<li><a onclick="showContent('3');">Link3</a></li>
</ul>
</li>
</ul>
</div>
showContent.js
<script>function showContent(cId)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("contentArea").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","contact/sendContent.php?cId="+cId,true);
xmlhttp.send();
}
sendContent.php
<?php
$cId=$_POST["cId"];
$tmp='error.php';
switch ($cId) {
case 1:{
$tmp='contact.php';
break;
}
case 2:{
$tmp='idCard.php';
break;
}
case 3:{
$tmp='location.php';
break;
}
}
ob_start();
include($tmp);
echo ob_get_clean();
?>
PS: テキスト エディターのボタンに使い方のヒントを追加する必要があります。コードの書式設定にこの吸盤エディターを使用する方法を理解するのに多くの時間を費やしました。
ヒント: このボタンを押してコードを選択してください!
知っていれば非常に簡単ですが、何かが本来の動作をしないと非常に面倒です!