Ik zie de fout niet..


index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="nl">
<head>
	<!-- no cache headers -->
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="-1" />
	<meta http-equiv="Cache-Control" content="no-cache" />
	<!-- end no cache headers -->
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<!-- CSS Stylesheet -->
	<style type="text/css">
	</style>
	<script type="text/javascript" src="./ajax.js"></script>
	<title>Wesdesignz - Rescripting your website!</title>
</head>
<body>
	<form method="post" action="./test.php">
		<input type="text" name="username" id="username" value="" /> &nbsp; <input type="submit" value="Verstuur formulier" onclick="javascript: load('./test.php', 'POST', 'answer'); return false;" />
	</form>
	<hr size="1" />
	<div id="answer">Laad de url</div>
</body>
</html>


ajax.js :

function load(url, mode, answer)
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange = function()
    {
		if ( xmlHttp.readyState == 4 )
		{
			document.getElementById( answer ).innerHTML = xmlHttp.responseText;
		}
    }
	xmlHttp.open(mode, url, true );
	if ( mode == 'POST' )
	{
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
	xmlHttp.send( null );
}


Het antwoord:
POST

Array
(
)

POST komt van $_SERVER['REQUEST_METHOD'] af.
Array () = print_r( $_POST );

Reageren