My problem is that I am trying to push one parameter via POST/GET, this parameter is passed to js function in coode bellow, all this files are in same directory.
Thy for help, answers. Best regards.
<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();
?>
P.S.: You should add hint on text editor's buttons how to use them, I spent a lot of time to figure out how to use this sucking editor for code formating.
Hint: select code pres this button!
Very easy when you know, very annoying if something do not behave like it should!
contact/sendContent.php?q="+contentIdwhereas you are accessingCIdon other page? It should be$_POST['q']cases out how look like...