<?php

$sAjax 
'HTTP_X_REQUESTED_WITH';
$bAjax = isset($_SERVER[$sAjax]) && $_SERVER[$sAjax] == 'XMLHttpRequest';

if(!
$bAjax) { ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">

<head>
  <title>Demo</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="robots" content="index,follow,all" />
  <meta name="Author" content="" />
  <meta name="Revisit-after" content="2 days" />
  <meta name="Keywords" content="" />
  <meta name="Description" content="" />
  <meta http-equiv="Content-Language" content="pl" />
  <script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript" src="jquery.autoload.js"></script>
  <script type="text/javascript">
    $(document).ready(function() {
      InitAjaxPost('field_submit');
    });
  </script>
</head>

<body id="root">
<?php ?>
<pre>
$_POST:
<?= var_dump($_POST?>
</pre>
  <form method="post">
  <fieldset>
    <p>field1: <input type="text" name="field1" /></p>
    <p>field2: <input type="text" name="field2" /></p>
    <p>field3: <select name="field3"><option value="1">1</option><option value="2">2</option></select></p>
    <p>field4: <input type="checkbox" name="field4" /></p>
    <input type="submit" id="field_submit" value="Submit it!" />
  </fieldset>
  </form>
<?php if(!$bAjax) { ?>
</body>
</html>
<?php ?>