Hondo
Verified User
I created a DA plugin to Start/Stop a chat server under the user's account. The plugin has one button which is used to both start and stop the chat server. The button initiates an AJAX script which in turn calls a PHP script. The PHP script basically determines the status of the chat server, and based on that status either starts or stops the server. Once the action is completed, the status of the server is returned to the AJAX script which presents the user with the status of the server underneath the button.
The issue: When the status is returned to the AJAX script, the header and the footer are redrawn in the iframe along with the status of the server.
Maybe I missed a post in my search, or maybe I'm Googleing the wrong words, so if anyone can point me in the right direction or share their expertise it would be greatly appreciated.
The issue: When the status is returned to the AJAX script, the header and the footer are redrawn in the iframe along with the status of the server.
Code:
#!/usr/local/bin/php
<!-- Start Palace Controls -->
<script language="JavaScript">
var xmlHttp;
function showStatus(){
xmlHttp = GetXmlHttpObject();
if(xmlHttp == null)
{
alert("Browser does not support HTTP Request.");
return;
}
var url="start-stop.php";
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged(){
if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete"){
document.getElementById("status").innerHTML = xmlHttp.responseText;
}
}
function GetXmlHttpObject(){
var xmlHttp = null;
try{
// FireFox, Opera, Safari
xmlHttp = new XMLHttpRequest();
}
catch(e){
// Internet Explorer
try{
xmlHttp = new ActiveXObject("Msxml12.XMLHTTP");
}
catch(e){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
<input value="Start/Stop" name="startstop" type="button" onclick="showStatus()" />
<p>Server Status: <span id="status"></span></p>