I have some ajax that loads php script output into a div. I would like the user then to be able to click on links in the output and rewrite the div without reloading the whole page. Is this possible in principle? Imagine code would look like:
html
<div id="displayhere"></div>
php1 output
echo '<a href="javascript:void(0);" onclick="reLoad(par1,par2,par3);">ChangeToNew</a>';
JS
function reLoad(par1,par2,par3) {
...
document.getElementById("displayhere").innerHTML=xmlhttp.responseText;
xmlhttp.open("GET","php2.php?par1="+par1 etc.,true);
xmlhttp.send();
php2
$par1 = $_get['par1'];
change database
echo '<a href="javascript:void(0);" onclick="reLoad(par1,par2,par3);">'.$par1.'</a>';
Could this in principle work or is the approach flawed?
Thanks.