Hello guys,
I don't know if there is already a solution for this but I'm having a lot of problems with re-loading the Ajax div tags.
At the moment I have two div tags in my main index.php file, called "flowchartDiv" and "buttondataDiv".
Now what I'm trying to do is when ever a image is clicked, "Image of a button", it is added to the database and the "flowchartDiv" must reload in-order to reflex the new button added to the database.
I will settle for the "flowchartDiv" reloading after a set time but I actually want the "flowchartDiv" to reload every time I click on the image buttons in the "buttondataDiv".
here is my code for index.php file:
<html>
<head>
<script type='text/javascript' src='ajax.js'>
window.onload=function(){
setTimeout('getXMLHttp()',2000);
</script>
<title>PHP AJAX Example</title>
</head>
<body>
<script>
getFlowButtons("popUp", "1")
</script>
<div id='flowchartDiv'>
</div>
<div id='buttondataDiv'>
</div>
<input type='button' onclick='loadButtons();' value='Edit'/>
</body>
</html>
Here is my ajax.js file:
function getXMLHttp()
{
var xmlHttp
try
{
//Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
//Internet Explorer
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
alert("Your browser does not support AJAX!")
return false;
}
}
}
return xmlHttp;
}
function getFlowButtons(popUp, flow_button_id)
{
var xmlHttp = getXMLHttp();
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
HandleResponse(xmlHttp.responseText);
}
}
xmlHttp.open("GET", 'ajax.php?action=getFlowButtons&
value='+flow_button_id, true);
xmlHttp.send(null);
}
function removeButtons(edit, button_id)
{
var xmlHttp = getXMLHttp();
var edit_Yes_No = edit;
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
HandleResponse(xmlHttp.responseText);
}
}
xmlHttp.open("GET", 'ajax.php?action=RemoveButton&
value='+button_id+'&value1='+edit_Yes_No, true);
xmlHttp.send(null);
}
function loadButtons()
{
var xmlHttp = getXMLHttp();
var loadButton = "loadButton";
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
HandleButtonDataResponse(xmlHttp.responseText);
}
}
xmlHttp.open('GET', 'ajax.php?action='+loadButton, true);
xmlHttp.send(null);
}
function addTo(popUp, button_id, button_url)
{
var xmlHttp = getXMLHttp();
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
HandleResponse(xmlHttp.responseText);
setTimeout('getXMLHttp()',1000);
}
}
xmlHttp.open("GET", 'ajax.php?action=addButton&
value='+button_id+'&value1='+button_url, true);
xmlHttp.send(null);
}
function HandleResponse(response)
{
document.getElementById('flowchartDiv').innerHTML += response;
setTimeout('getXMLHttp()',1000);
}
function HandleButtonDataResponse(response)
{
document.getElementById('buttondataDiv').innerHTML +=
response;
}
Now in the function HandleResponse(response)
function you can see I have already tried to in corporate the timer but nothing is working at the moment.
Hope someone can help me
Take care