<?
if (!empty($_POST)) {
    for (
$i=0$i<99$i++) {
        
printf("PHP says the time is: %s\x00"date('r'));
        
flush();
        
sleep(rand(1,3));
    }
}
?>
<!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="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Partial-load AJAX</title>
<style type="text/css">
</style>
<script type="text/javascript">
function ajax_init() {
    var ajax_obj=null;
    try {
        ajax_obj=new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
        try {
            ajax_obj=new ActiveXObject('Microsoft.XMLHTTP');
        } catch (e) {
            ajax_obj=null;
        }
    }
    if (!ajax_obj && 'undefined'!=typeof(XMLHttpRequest)) {
        ajax_obj = new XMLHttpRequest();
    }
    return ajax_obj;
}

function ajax_request(aUri, aData, aMode) {
    if ('undefined'==typeof(aMode)) {
        var mode='GET';
    } else {
        var mode=aMode;
    }
    if ('undefined'==typeof(aData)) {
        var aData=new Array();
    }

    var ajax_obj=ajax_init();
    if (!ajax_obj) return;
    
    var data='';
    for (k in aData) {
        data+='&'+escape(k)+'='+escape(aData[k]);
    }
    data=data.substr(1);

    if ('GET'==mode) {
        aUri+='?'+data;
        data=null;
    }
    ajax_obj.open(mode, aUri, true);
    if ('POST'==mode) {
        ajax_obj.setRequestHeader('Method', 'POST '+aUri+' HTTP/1.1');
        ajax_obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }

    //ajax_obj.offset=0;
    ajax_obj.onreadystatechange=function() {
        var response=ajax_obj.responseText;
        response=response.substr(ajax_obj.offset);
        var end=response.indexOf('\x00');
        if (-1==end) return;
        ajax_obj.offset+=end+1;
        response=response.substr(0, end);
        
        document.getElementById('output').value=response;
    }

    ajax_obj.send(data);

    return true;
}

function runIt() {
    ajax_request(document.location.href, {feedme:1}, 'POST');
}
</script>
</head>
<body>

<p>This is a simple demonstration, to show that <a href='http://ajaxian.com/archives/phpclassesorg-chooses-iframes-over-ajax'>this statement</a> is false:</p>
<blockquote>with an Ajax connection, one can only get to the data once the request is complete.</blockquote>

<textarea id='output' rows='10' cols='' style='width: 100%;'></textarea>
<button type='button' onclick='runIt();'>Run it!</button>

<p><a href='ajax-partial.phps'>View the source</a> to believe it.</p>

<hr />

<p>Augh!  Internet Explorer, the bane of the web!  I see, it is partially true.</p>

</body>
</html>