<?php
// No cache in the web browser
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Ingen cache i IE
header("Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT" );
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: text/plain");
// Create safe html and URL encod it
function safeHTMLEncode($strMessage){
$strMessage = urlencode(htmlentities($strMessage));
return $strMessage;
}
// If any action should be performed
$action = $_GET['action'];
if(isset($action)){
// Yes, check what action to perform
if($action == "helloworld"){
// Print the Hello World message
echo "text=".safeHTMLEncode("Hello World!\nThis is my first AJAX script...");
}
else{
// Unknown action
echo "text=".safeHTMLEncode("Error! Unknown command \"{$action}\".");
}
}
else {
// No, write errromessage
echo "text=".safeHTMLEncode("Error! No command was sent.");
}
?>