All pastes #2069157 Raw Edit

Anonymous

public text v1 · immutable
#2069157 ·published 2011-05-25 20:39 UTC
rendered paste body
# File ajax.js

<script>
function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

//Function used to update page content with new xhtml fragments by using a javascript object, the dom, and http.
function getAXAH(url){
	var theHttpRequest = getNewHttpObject();
	theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);};
	theHttpRequest.open("GET", url);
	theHttpRequest.send(false);

		function processAXAH(elementContainer){
		   if (theHttpRequest.readyState == 4) {
			   if (theHttpRequest.status == 200) {
				   document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;
			   }
		   }
		}

}

</script>

# File: write.php

<?

$event = $_GET['event'];

if ($event == 1)
{
  $txt = 'log1.txt'
}
else
{
  $txt = 'log2.txt';
}

if (file_exists($txt))
{
  $fh = fopen($txt, 'w') or exit;
  $data = file($txt)
  $add = 1 + $data[0];
  fwrite($fh, $add);
  fclose($fh);
}

?>

# File: landingPage.html

<html>
<script src="ajax.js">

if something
{

  doEvent1();
  getAXAH('write.php?event=1')

}
else
{
  doEvent2();
  getAXAH('write.php?event=2')
}

</script>
</html>